add comments

This commit is contained in:
Namekuji 2023-06-16 03:45:53 -04:00
parent 7a35aaa51d
commit eb7b1d6788

View File

@ -457,17 +457,21 @@ export default async (
if (!dontFederateInitially) { if (!dontFederateInitially) {
const relays = await getCachedRelays(); 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 = const boostedByRelay =
!!user.inbox && !!user.inbox &&
relays.map((relay) => relay.inbox).includes(user.inbox); relays.map((relay) => relay.inbox).includes(user.inbox);
if (!note.uri) { if (!note.uri) {
// Publish if the post is local
publishNotesStream(note); publishNotesStream(note);
} else if ( } else if (
boostedByRelay && boostedByRelay &&
data.renote?.uri && data.renote?.uri &&
(await redisClient.exists(`publishedNote:${data.renote.uri}`)) === 0 (await redisClient.exists(`publishedNote:${data.renote.uri}`)) === 0
) { ) {
// Publish if the post was boosted by a relay and not yet published.
publishNotesStream(data.renote); publishNotesStream(data.renote);
const key = `publishedNote:${data.renote.uri}`; const key = `publishedNote:${data.renote.uri}`;
await redisClient.set(key, 1, "EX", 30); await redisClient.set(key, 1, "EX", 30);
@ -476,6 +480,9 @@ export default async (
note.uri && note.uri &&
(await redisClient.exists(`publishedNote:${note.uri}`)) === 0 (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}`; const key = `publishedNote:${note.uri}`;
publishNotesStream(note); publishNotesStream(note);
await redisClient.set(key, 1, "EX", 30); await redisClient.set(key, 1, "EX", 30);