Repository navigation
feat(nip43): publish the kind 13534 membership list #1199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| 'nostream': minor | ||
| --- | ||
|
|
||
| feat(nip43): publish the kind 13534 membership list | ||
|
|
||
| With the new `nip43.publishMembershipList` setting (off by default) the relay publishes a replaceable kind 13534 event, signed by its own key, with the NIP-70 `-` tag and one `member` tag per admitted pubkey, and refreshes it after every successful join or leave, and when a member's request to vanish is accepted, so that pubkey is taken out of it. Joins and leaves that are rejected or change nothing do not refresh it. Nothing is published when `info.self` does not match the relay's signing pubkey, since NIP-43 requires that signer. The list makes every member's pubkey public to anyone who can read the relay, which is why the setting defaults to off. It is a convenience for clients, not the source of truth for who may publish, and it holds at most the first 10,000 members. Users who asked to vanish are left out. Admissions made another way, for example a paid admission, do not refresh it. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import { Event } from '../../@types/event' | |
| import { EventKinds } from '../../constants/base' | ||
| import { IEventStrategy } from '../../@types/message-handlers' | ||
| import { IWebSocketAdapter } from '../../@types/adapters' | ||
| import { MembershipListPublisher } from '../../utils/nip43-membership' | ||
| import { WebSocketAdapterEvent } from '../../constants/adapter' | ||
|
|
||
| const logger = createLogger('vanish-event-strategy') | ||
|
|
@@ -14,6 +15,7 @@ export class VanishEventStrategy implements IEventStrategy<Event, Promise<void>> | |
| private readonly webSocket: IWebSocketAdapter, | ||
| private readonly eventRepository: IEventRepository, | ||
| private readonly userRepository: IUserRepository, | ||
| private readonly membershipList?: MembershipListPublisher, | ||
| ) {} | ||
|
|
||
| public async execute(event: Event): Promise<void> { | ||
|
|
@@ -25,6 +27,14 @@ export class VanishEventStrategy implements IEventStrategy<Event, Promise<void>> | |
|
|
||
| await this.userRepository.setVanished(event.pubkey, true) | ||
|
|
||
| // A member who vanishes is left out of the published membership list, which only changes when it is refreshed. | ||
| // The vanish itself is done whether or not the list could be refreshed. | ||
| try { | ||
| await this.membershipList?.refresh() | ||
|
Comment on lines
+30
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Replaying an accepted vanish request refreshes the entire membership list, even when the user has already vanished and Each refresh advances |
||
| } catch (error) { | ||
| logger('unable to refresh the membership list after %s vanished: %o', event.pubkey, error) | ||
| } | ||
|
|
||
| this.webSocket.emit(WebSocketAdapterEvent.Message, createEventCommandResult(event.id, true, count ? '' : 'duplicate:')) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.