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,