From b6f8e2fd051051d5ad9592d02b1663488f77762d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 11 Jun 2022 19:50:05 -0400 Subject: [PATCH] fix: #10692 --- src/topics/tags.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/topics/tags.js b/src/topics/tags.js index 7d585771d3..655c18345f 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -113,6 +113,13 @@ module.exports = function (Topics) { await db.sortedSetAdd('tags:topic:count', 0, tag); cache.del('tags:topic:count'); } + const allCids = await categories.getAllCidsFromSet('categories:cid'); + const isMembers = await db.isMemberOfSortedSets( + allCids.map(cid => `cid:${cid}:tags`), tag + ); + const bulkAdd = allCids.filter((cid, index) => !isMembers[index]) + .map(cid => ([`cid:${cid}:tags`, 0, tag])); + await db.sortedSetAddBulk(bulkAdd); }; Topics.renameTags = async function (data) {