From 2b1e16d48991cb8c9bfe15043a297ab1c783b863 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Fri, 16 Jun 2023 03:45:53 -0400 Subject: [PATCH] add comments --- packages/backend/src/services/note/create.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 3423ef01d..b493ae5e0 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -457,17 +457,21 @@ export default async ( if (!dontFederateInitially) { const relays = await getCachedRelays(); + // Some relays (e.g., aode-relay) deliver posts by boosting them as + // Announce activities. In that case, user is the relay's actor. const boostedByRelay = !!user.inbox && relays.map((relay) => relay.inbox).includes(user.inbox); if (!note.uri) { + // Publish if the post is local publishNotesStream(note); } else if ( boostedByRelay && data.renote?.uri && (await redisClient.exists(`publishedNote:${data.renote.uri}`)) === 0 ) { + // Publish if the post was boosted by a relay and not yet published. publishNotesStream(data.renote); const key = `publishedNote:${data.renote.uri}`; await redisClient.set(key, 1, "EX", 30); @@ -476,6 +480,9 @@ export default async ( note.uri && (await redisClient.exists(`publishedNote:${note.uri}`)) === 0 ) { + // Publish if the post came directly from a remote server, or from a + // relay that doesn't boost the post (e.g, YUKIMOCHI Activity-Relay), + // and not yet published. const key = `publishedNote:${note.uri}`; publishNotesStream(note); await redisClient.set(key, 1, "EX", 30);