From 3b72ff8742daa679d4c545260af9b94a49300768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 18 Jan 2022 20:12:50 -0500 Subject: [PATCH] fix: dont add duplicate link backs --- src/topics/posts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/topics/posts.js b/src/topics/posts.js index 52146c7af0..721488b434 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -370,7 +370,7 @@ module.exports = function (Topics) { } const { pid, uid, tid } = postData; - let add = matches.map(match => match[1]).map(tid => parseInt(tid, 10)); + let add = _.uniq(matches.map(match => match[1]).map(tid => parseInt(tid, 10))); const now = Date.now(); const topicsExist = await Topics.exists(add); @@ -382,7 +382,7 @@ module.exports = function (Topics) { await db.sortedSetRemove(`pid:${pid}:backlinks`, remove); // Add new backlinks - await db.sortedSetAdd(`pid:${pid}:backlinks`, add.map(Number.bind(null, now)), add); + await db.sortedSetAdd(`pid:${pid}:backlinks`, add.map(() => now), add); await Promise.all(add.map(async (tid) => { await Topics.events.log(tid, { uid,