feat: add GET /relay/{id}/members endpoint #6

Merged
hodlbod merged 1 commits from userAdityaa/zooid:relay-members-endpoint into master 2026-04-22 20:45:28 +00:00
Contributor

Description

Implemented GET /relay/{id}/members endpoint that returns the current member list for a relay by querying both live relay state and persisted configuration.

Member Resolution: Two-Tier Approach

The endpoint resolves members using a priority-based strategy:

Tier 1: Live Relay (Real-time)

If the relay is currently running (loaded in instancesByName):

  • Queries the live ManagementStore.GetMembers()
  • Returns members from the active relay-members event (kind 13534)
  • Reflects real-time membership changes

Tier 2: Config Fallback (Offline)

If relay is not loaded or not running:

  • Loads the relay config file ({id}.toml)
  • Aggregates members from 4 sources:
    1. Owner (config.Info.Pubkey) —> relay creator
    2. Relay Secret Holder (config.Secret public key) —> relay operator
    3. Role Members (config.Roles[*].Pubkeys[]) —> admins, moderators, etc.
    4. Dynamic Members (management.GetMembers()) —> members added via NoStr events but persisted to disk

Added due to: coracle/caravel#33, coracle/caravel#43

### Description Implemented `GET /relay/{id}/members` endpoint that returns the current member list for a relay by querying both live relay state and persisted configuration. ### Member Resolution: Two-Tier Approach The endpoint resolves members using a priority-based strategy: **Tier 1: Live Relay (Real-time)** If the relay is currently running (loaded in instancesByName): * Queries the live ManagementStore.GetMembers() * Returns members from the active relay-members event (kind 13534) * Reflects real-time membership changes **Tier 2: Config Fallback (Offline)** If relay is not loaded or not running: * Loads the relay config file ({id}.toml) * Aggregates members from 4 sources: 1. Owner (config.Info.Pubkey) —> relay creator 2. Relay Secret Holder (config.Secret public key) —> relay operator 3. Role Members (config.Roles[*].Pubkeys[]) —> admins, moderators, etc. 4. Dynamic Members (management.GetMembers()) —> members added via NoStr events but persisted to disk Added due to: https://gitea.coracle.social/coracle/caravel/issues/33, https://gitea.coracle.social/coracle/caravel/pulls/43
userAdityaa changed title from feat: add GET /relay/{id}/members endpoint to feat: add `GET /relay/{id}/members` endpoint 2026-04-22 18:26:36 +00:00
hodlbod reviewed 2026-04-22 18:34:04 +00:00
zooid/api.go Outdated
@@ -84,0 +166,4 @@
memberSet[pubkey.Hex()] = struct{}{}
}
return sortedMembers(memberSet), nil
Owner

Instead of doing this all manually, do some refactoring in lib.go so that we can MakeInstance and clean it up when we're done (if it's inactive). It's a little bit overkill, but instances shouldn't be terribly heavy.

Instead of doing this all manually, do some refactoring in lib.go so that we can `MakeInstance` and clean it up when we're done (if it's inactive). It's a little bit overkill, but instances shouldn't be terribly heavy.
Author
Contributor

Done. Makes sense to eliminate the manual path entirely, this refactor removes all ad hoc member assembly and centralizes lifecycle management in a single place.

Done. Makes sense to eliminate the manual path entirely, this refactor removes all ad hoc member assembly and centralizes lifecycle management in a single place.
userAdityaa added 1 commit 2026-04-22 19:13:15 +00:00
userAdityaa force-pushed relay-members-endpoint from 100c771d55 to 9ed0d72ca9 2026-04-22 19:13:15 +00:00 Compare
hodlbod merged commit aa0eba1fbe into master 2026-04-22 20:45:28 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coracle/zooid#6