mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: get author from grant event (30360), before doing the admin deletion
This commit is contained in:
parent
dd5397e795
commit
d8a0eca891
2 changed files with 30 additions and 4 deletions
|
|
@ -95,13 +95,29 @@ Deno.test('Admin revokes nip05 grant and nip05 column gets null', async () => {
|
||||||
assertEquals(row?.nip05_domain, 'gleasonator.dev');
|
assertEquals(row?.nip05_domain, 'gleasonator.dev');
|
||||||
assertEquals(row?.nip05_hostname, 'gleasonator.dev');
|
assertEquals(row?.nip05_hostname, 'gleasonator.dev');
|
||||||
|
|
||||||
|
const grant = await conf.signer.signEvent({
|
||||||
|
kind: 30360,
|
||||||
|
tags: [
|
||||||
|
['d', 'alex@gleasonator.dev'],
|
||||||
|
['r', 'alex@gleasonator.dev'],
|
||||||
|
['L', 'nip05.domain'],
|
||||||
|
['l', 'gleasonator.dev', 'nip05.domain'],
|
||||||
|
['p', event.pubkey],
|
||||||
|
['e', 'whatever'],
|
||||||
|
],
|
||||||
|
created_at: nostrNow(),
|
||||||
|
content: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
await store.event(grant);
|
||||||
|
|
||||||
const adminDeletion = await conf.signer.signEvent({
|
const adminDeletion = await conf.signer.signEvent({
|
||||||
kind: 5,
|
kind: 5,
|
||||||
created_at: nostrNow(),
|
|
||||||
tags: [
|
tags: [
|
||||||
['k', '30360'],
|
['k', '30360'],
|
||||||
['p', event.pubkey], // NOTE: this is not in the NIP-09 spec
|
['e', grant.id],
|
||||||
],
|
],
|
||||||
|
created_at: nostrNow(),
|
||||||
content: '',
|
content: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,11 +183,11 @@ export class DittoRelayStore implements NRelay {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
await this.handleRevokeNip05(event, signal);
|
||||||
await relay.event(purifyEvent(event), { signal });
|
await relay.event(purifyEvent(event), { signal });
|
||||||
} finally {
|
} finally {
|
||||||
// This needs to run in steps, and should not block the API from responding.
|
// This needs to run in steps, and should not block the API from responding.
|
||||||
await Promise.allSettled([
|
await Promise.allSettled([
|
||||||
this.handleRevokeNip05(event, signal),
|
|
||||||
this.handleZaps(event),
|
this.handleZaps(event),
|
||||||
this.updateAuthorData(event, signal),
|
this.updateAuthorData(event, signal),
|
||||||
this.prewarmLinkPreview(event, signal),
|
this.prewarmLinkPreview(event, signal),
|
||||||
|
|
@ -258,7 +258,17 @@ export class DittoRelayStore implements NRelay {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const authorId = event.tags.find(([name]) => name === 'p')?.[1];
|
const eventId = event.tags.find(([name]) => name === 'e')?.[1];
|
||||||
|
if (!eventId || !isNostrId(eventId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [grant] = await relay.query([{ kinds: [30360], ids: [eventId] }], { signal });
|
||||||
|
if (!grant) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const authorId = grant.tags.find(([name]) => name === 'p')?.[1];
|
||||||
if (!authorId || !isNostrId(authorId)) {
|
if (!authorId || !isNostrId(authorId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue