Improve handle registry healing and gossip propagation

Added healing utilities to update the handle registry when a user profile is found at a new node domain. Enhanced upsertHandleEntries to accept a sourceDomain parameter, allowing authoritative updates from the owning node. Updated gossip logic to pass sender/target domains for proper trust handling during handle propagation. Integrated healing logic into chat key lookup to keep the registry accurate.
This commit is contained in:
Christopher
2026-01-28 06:55:13 -08:00
parent 213dcc8095
commit 36f653d500
4 changed files with 111 additions and 18 deletions
+4
View File
@@ -3,6 +3,7 @@ import { db } from '@/db';
import { chatDeviceBundles, handleRegistry, remoteIdentityCache } from '@/db/schema';
import { requireAuth } from '@/lib/auth';
import { eq, and, gt } from 'drizzle-orm';
import { updateRegistryFromProfile } from '@/lib/swarm/healing';
/**
* GET /api/chat/keys?did=<did>
@@ -115,6 +116,9 @@ export async function GET(request: NextRequest) {
if (chatKey) {
console.log('[Chat Keys GET] Found key in Swarm Profile');
// HEALING: Update the registry because we found the user at this nodeDomain!
await updateRegistryFromProfile(handleEntry.handle, did, nodeDomain);
// Cache it
await db.insert(remoteIdentityCache).values({
did: did,