feat(social): federated branch for POST /api/social/requests (happy path)

Refactors the POST handler into handleLocalFriendRequest + handleFederatedFriendRequest helpers. The federated branch resolves the target domain, ensures peering, looks up the remote user, creates/hydrates a replicated stub, and writes a transactional (friend_requests + mutation_log + outbox) event with relayMessageId set. Also exports hydrateReplicatedUserProfile from federation.ts and adds the T11 happy-path test.
This commit is contained in:
Jannis Braun
2026-04-25 22:04:36 +02:00
parent 08872f1e08
commit 0574a10ff3
4 changed files with 465 additions and 113 deletions
+4 -3
View File
@@ -53,9 +53,10 @@ vi.mock('../utils/federationOutbox.js', () => ({
getFriendEventTargets: () => [],
}));
vi.mock('../utils/federationAuth.js', () => ({
getOurOrigin: () => 'https://local.test',
}));
vi.mock('../utils/federationAuth.js', async (importActual) => {
const actual = await importActual<typeof import('../utils/federationAuth.js')>();
return { ...actual, getOurOrigin: () => 'https://local.test' };
});
function applyMigrations(db: Database.Database): void {
const migrationsDir = path.resolve(__dirname, '../../drizzle');