Conversation
src/utils/event.ts
Outdated
| export const isValidRequestToVanishEvent = (event: Event, relayUrl: string): boolean => { | ||
| const relayTags = event.tags | ||
| .filter((tag) => tag.length >= 2 && tag[0] === EventTags.Relay) | ||
| .map((tag) => tag[1]) | ||
|
|
||
| return relayTags.length > 0 && relayTags.every((relay) => relay === relayUrl || relay === ALL_RELAYS) | ||
| } |
There was a problem hiding this comment.
is this missing the kind number check?
There was a problem hiding this comment.
do we need two functions? I think we just need 1 combining these two.
There was a problem hiding this comment.
do we need two functions? I think we just need 1 combining these two.
Yes , we can combine these two to make single function to validate eligibility.If you want I can make the changes update the tests according to it
There was a problem hiding this comment.
@vikashsiwach Let's merge them please, having two functions can lead to confusion on which one is right one to use.
| public async hasActiveRequestToVanish(pubkey: string): Promise<boolean> { | ||
| const result = await this.readReplicaDbClient('events') | ||
| .select('event_id') | ||
| .where('event_pubkey', toBuffer(pubkey)) | ||
| .where('event_kind', EventKinds.REQUEST_TO_VANISH) | ||
| .whereNull('deleted_at') | ||
| .first() | ||
|
|
||
| return Boolean(result) |
There was a problem hiding this comment.
We are likely better off adding a column to the users table. However, I think I am okay with this approach for now. Optimizing this to use the users table can be a separate issue.
There was a problem hiding this comment.
You are right , a table flag will would be better for long term optimization. I used this event based check to stay scoped to NIP-62 behavior. We can create a follow up issue for this if you want.
|
@vikashsiwach Impressive work! Just left a few comments. |
|
Merged vanish validation and kind check in single function. Have a look on it ! |
* feat: add NIP-62 vanish event support (#418) * ci: remove sonarcloud step from checks workflow --------- Co-authored-by: Vikash Siwach <siwachvikash70@gmail.com> Co-authored-by: github-manager <github-manager@example.com> Co-authored-by: Ricardo Cabral <me@ricardocabral.io>
Description
This PR implement support for NIP-62 request-to-vanish events. When a vanish event is received ,the relay deletes all existing events for that pubkey and keep only kind:62 event as tombstone.
Afterwards, all events from that pubkey are rejected.
Additional behavior:
Related Issue
Fixes issue #390
Motivation and Context
NIP-62 is meant to allow users to erase their presence on a relay. This is implemented in this PR by treating kind:62 as tombstone.
How Has This Been Tested?
Types of changes
Checklist: