mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
18 lines
636 B
TypeScript
18 lines
636 B
TypeScript
import { NostrEvent, NostrRelayOK, NPolicy, NStore } from '@nostrify/nostrify';
|
|
|
|
import { getTagSet } from '@ditto/utils/tags';
|
|
|
|
export class MuteListPolicy implements NPolicy {
|
|
constructor(private pubkey: string, private store: NStore) {}
|
|
|
|
async call(event: NostrEvent): Promise<NostrRelayOK> {
|
|
const [muteList] = await this.store.query([{ authors: [this.pubkey], kinds: [10000], limit: 1 }]);
|
|
const pubkeys = getTagSet(muteList?.tags ?? [], 'p');
|
|
|
|
if (pubkeys.has(event.pubkey)) {
|
|
return ['OK', event.id, false, 'blocked: Your account has been deactivated.'];
|
|
}
|
|
|
|
return ['OK', event.id, true, ''];
|
|
}
|
|
}
|