Merge remote-tracking branch 'origin/lowercase-nip05' into router

This commit is contained in:
Alex Gleason 2025-02-21 21:54:32 -06:00
commit 8ef03e7926
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
4 changed files with 20 additions and 8 deletions

View file

@ -190,7 +190,7 @@ const adminApproveController: AppController = async (c) => {
} }
const [existing] = await relay.query([ const [existing] = await relay.query([
{ kinds: [30360], authors: [await conf.signer.getPublicKey()], '#d': [r], limit: 1 }, { kinds: [30360], authors: [await conf.signer.getPublicKey()], '#d': [r.toLowerCase()], limit: 1 },
]); ]);
if (existing) { if (existing) {
@ -200,7 +200,8 @@ const adminApproveController: AppController = async (c) => {
await createAdminEvent({ await createAdminEvent({
kind: 30360, kind: 30360,
tags: [ tags: [
['d', r], ['d', r.toLowerCase()],
['r', r],
['L', 'nip05.domain'], ['L', 'nip05.domain'],
['l', r.split('@')[1], 'nip05.domain'], ['l', r.split('@')[1], 'nip05.domain'],
['p', event.pubkey], ['p', event.pubkey],

View file

@ -88,16 +88,22 @@ export const nameRequestController: AppController = async (c) => {
const { name, reason } = result.data; const { name, reason } = result.data;
const [existing] = await relay.query([{ kinds: [3036], authors: [pubkey], '#r': [name], limit: 1 }]); const [existing] = await relay.query([{ kinds: [3036], authors: [pubkey], '#r': [name.toLowerCase()], limit: 1 }]);
if (existing) { if (existing) {
return c.json({ error: 'Name request already exists' }, 400); return c.json({ error: 'Name request already exists' }, 400);
} }
const r: string[][] = [['r', name]];
if (name !== name.toLowerCase()) {
r.push(['r', name.toLowerCase()]);
}
const event = await createEvent({ const event = await createEvent({
kind: 3036, kind: 3036,
content: reason, content: reason,
tags: [ tags: [
['r', name], ...r,
['L', 'nip05.domain'], ['L', 'nip05.domain'],
['l', name.split('@')[1], 'nip05.domain'], ['l', name.split('@')[1], 'nip05.domain'],
['p', await conf.signer.getPublicKey()], ['p', await conf.signer.getPublicKey()],

View file

@ -54,9 +54,11 @@ async function getNip05(
} }
export async function localNip05Lookup(store: NStore, localpart: string): Promise<nip19.ProfilePointer | undefined> { export async function localNip05Lookup(store: NStore, localpart: string): Promise<nip19.ProfilePointer | undefined> {
const name = `${localpart}@${Conf.url.host}`;
const [grant] = await store.query([{ const [grant] = await store.query([{
kinds: [30360], kinds: [30360],
'#d': [`${localpart}@${Conf.url.host}`], '#d': [name, name.toLowerCase()],
authors: [await Conf.signer.getPublicKey()], authors: [await Conf.signer.getPublicKey()],
limit: 1, limit: 1,
}]); }]);

View file

@ -99,15 +99,18 @@ async function renderReaction(event: DittoEvent, opts: RenderNotificationOpts) {
} }
async function renderNameGrant(event: DittoEvent) { async function renderNameGrant(event: DittoEvent) {
const r = event.tags.find(([name]) => name === 'r')?.[1];
const d = event.tags.find(([name]) => name === 'd')?.[1]; const d = event.tags.find(([name]) => name === 'd')?.[1];
const account = event.author ? await renderAccount(event.author) : await accountFromPubkey(event.pubkey); const name = r ?? d;
if (!d) return; if (name) return;
const account = event.author ? await renderAccount(event.author) : await accountFromPubkey(event.pubkey);
return { return {
id: notificationId(event), id: notificationId(event),
type: 'ditto:name_grant' as const, type: 'ditto:name_grant' as const,
name: d, name,
created_at: nostrDate(event.created_at).toISOString(), created_at: nostrDate(event.created_at).toISOString(),
account, account,
}; };