og-badges: tidy log line
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVFi3wvLWKaEkpDw6eLnQC
This commit is contained in:
1 parent
9bf8aeceff
commit
be2f699456
1 file changed
+1
-5
@@ -48,7 +48,6 @@ jobs:
|
||||
const RELAYS = process.env.RELAYS.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
const A = `30009:${WK.pk}:og`;
|
||||
const now = () => Math.floor(Date.now() / 1000);
|
||||
|
||||
const sign = (k, kind, tags, content = '') => {
|
||||
const ev = { pubkey: k.pk, created_at: now(), kind, tags, content };
|
||||
ev.id = createHash('sha256').update(JSON.stringify([0, ev.pubkey, ev.created_at, ev.kind, ev.tags, ev.content])).digest('hex');
|
||||
@@ -77,7 +76,6 @@ jobs:
|
||||
if (!ok) process.exitCode = 1;
|
||||
return ok;
|
||||
};
|
||||
|
||||
// 1. definition
|
||||
const defs = await query({ kinds: [30009], authors: [WK.pk], '#d': ['og'] });
|
||||
if (!defs.length || process.env.REPUBLISH === 'true') {
|
||||
@@ -86,18 +84,16 @@ jobs:
|
||||
['description', 'One of the first names on well-known.online: an OG handle, with a free inbox at name@well-known.online.'],
|
||||
['image', img, '512x512'], ['thumb', img, '512x512']]), 'definition');
|
||||
} else console.log('definition: present', defs[0].id);
|
||||
|
||||
// 2. diff directory vs awards
|
||||
const dir = await (await fetch(process.env.OG_DIR)).json();
|
||||
const ogKeys = [...new Set(Object.values(dir.names || {}).map((k) => String(k).toLowerCase()).filter((k) => /^[0-9a-f]{64}$/.test(k)))];
|
||||
const awards = await query({ kinds: [8], authors: [WK.pk], '#a': [A] });
|
||||
const awarded = new Set(awards.flatMap((e) => e.tags.filter((t) => t[0] === 'p').map((t) => t[1])));
|
||||
const missing = ogKeys.filter((k) => !awarded.has(k));
|
||||
console.log(`og directory: ${ogKeys.length} keys; already awarded: ${[...awarded].length}; to award: ${missing.length}`);
|
||||
console.log(`og directory: ${ogKeys.length} keys; already awarded: ${awarded.size}; to award: ${missing.length}`);
|
||||
for (let i = 0; i < missing.length; i += 50) {
|
||||
await publish(sign(WK, 8, [['a', A], ...missing.slice(i, i + 50).map((p) => ['p', p, RELAYS[0]])]), 'award');
|
||||
}
|
||||
|
||||
// 3. our own keys accept (kind 30008 profile_badges), once
|
||||
const allAwards = missing.length ? await query({ kinds: [8], authors: [WK.pk], '#a': [A] }) : awards;
|
||||
for (const [label, k] of [['factory', FACTORY], ['well-known', WK]]) {
|
||||
|
||||
Reference in new issue
Block a user