diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js index dfe9ef2435..a8f84eea80 100644 --- a/src/activitypub/notes.js +++ b/src/activitypub/notes.js @@ -414,9 +414,9 @@ Notes.getParentChain = async (uid, input) => { }; Notes.syncUserInboxes = async function (tid, uid) { - const [pids, { cid, mainPid }] = await Promise.all([ + const [pids, { cid, mainPid, tags }] = await Promise.all([ db.getSortedSetMembers(`tid:${tid}:posts`), - topics.getTopicFields(tid, ['tid', 'cid', 'mainPid']), + topics.getTopicFields(tid, ['tid', 'cid', 'mainPid', 'tags']), ]); pids.unshift(mainPid); @@ -426,6 +426,12 @@ Notes.syncUserInboxes = async function (tid, uid) { uids.add(parseInt(uid, 10)); } + // Tag followers + const tagsFollowers = await topics.getTagsFollowers(tags.map(tag => tag.value)); + new Set(tagsFollowers.flat()).forEach((uid) => { + uids.add(uid); + }); + const keys = Array.from(uids).map(uid => `uid:${uid}:inbox`); const score = await db.sortedSetScore(`cid:${cid}:tids`, tid); diff --git a/src/topics/tags.js b/src/topics/tags.js index 4f2bc6dc97..378f919a16 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -564,6 +564,10 @@ module.exports = function (Topics) { return await db.getSortedSetRange(`tag:${tag}:followers`, start, stop); }; + Topics.getTagsFollowers = async function (tags) { + return await db.getSortedSetsMembers(tags.map(tag => `tag:${tag}:followers`)); + }; + Topics.followTag = async (tag, uid) => { if (!(parseInt(uid, 10) > 0)) { throw new Error('[[error:not-logged-in]]');