diff --git a/src/activitypub/feps.js b/src/activitypub/feps.js index 9fb0e28680..01fc3d46d0 100644 --- a/src/activitypub/feps.js +++ b/src/activitypub/feps.js @@ -23,7 +23,8 @@ Feps.announce = async function announce(id, activity) { const tid = await posts.getPostField(localId || id, 'tid'); const cid = await topics.getTopicField(tid, 'cid'); const localCid = utils.isNumber(cid) && cid > 0; - const shouldAnnounce = localCid || utils.isNumber(tid); + const addressed = activitypub.helpers.addressed(cid, activity); + const shouldAnnounce = localCid || (utils.isNumber(tid) && !addressed); if (!shouldAnnounce) { // inverse conditionals can kiss my ass. return; } diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.js index 90701dd58d..6628b3ec55 100644 --- a/src/activitypub/helpers.js +++ b/src/activitypub/helpers.js @@ -526,3 +526,20 @@ Helpers.generateDigest = (set) => { return result.toString('hex'); }); }; + +Helpers.addressed = (id, activity) => { + // Returns Boolean for if id is found in addressing fields (to, cc, etc.) + if (!id || !activity || typeof activity !== 'object') { + return false; + } + + const combined = new Set([ + ...(activity.to || []), + ...(activity.cc || []), + ...(activity.bto || []), + ...(activity.bcc || []), + ...(activity.audience || []), + ]); + + return combined.has(id); +};