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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user