AppView in a box as a Vite plugin thing hatk.dev
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: update handles from firehose #identity events

Listen for #identity events on the relay and update the handle in
_repos for tracked DIDs when it changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+16
+5
packages/hatk/src/database/db.ts
··· 413 413 } 414 414 } 415 415 416 + /** Update the handle for a DID if it exists in _repos. */ 417 + export async function updateRepoHandle(did: string, handle: string): Promise<void> { 418 + await run(`UPDATE _repos SET handle = $1 WHERE did = $2`, [handle, did]) 419 + } 420 + 416 421 export async function getRepoRev(did: string): Promise<string | null> { 417 422 const rows = await all<{ rev: string }>(`SELECT rev FROM _repos WHERE did = $1`, [did]) 418 423 return rows[0]?.rev ?? null
+11
packages/hatk/src/indexer.ts
··· 8 8 getRepoRetryInfo, 9 9 listAllRepoStatuses, 10 10 getDatabasePort, 11 + updateRepoHandle, 11 12 } from './database/db.ts' 12 13 import { backfillRepo } from './backfill.ts' 13 14 import { rebuildAllIndexes } from './database/fts.ts' ··· 349 350 function processMessage(bytes: Uint8Array, collections: Set<string>): void { 350 351 const header = cborDecode(bytes, 0) 351 352 const body = cborDecode(bytes, header.offset) 353 + 354 + // Handle identity events (handle changes) 355 + if (header.value.t === '#identity') { 356 + const did = body.value.did 357 + const handle = body.value.handle 358 + if (did && handle && repoStatusCache.has(did)) { 359 + updateRepoHandle(did, handle).catch(() => {}) 360 + } 361 + return 362 + } 352 363 353 364 if (header.value.op !== 1 || header.value.t !== '#commit') return 354 365 if (!body.value.blocks || !body.value.ops) return