From d734ce4911d44fdd7559c4625604b0fcdf009755 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 16 Dec 2024 22:34:26 -0500 Subject: [PATCH] fix: ignore subsequent shares of the same topic by that user --- src/topics/tools.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/topics/tools.js b/src/topics/tools.js index e102437ccf..13bbd5ece7 100644 --- a/src/topics/tools.js +++ b/src/topics/tools.js @@ -302,9 +302,15 @@ module.exports = function (Topics) { }; topicTools.share = async function (tid, uid, timestamp = Date.now()) { + const set = `uid:${uid}:shares`; + const shared = await db.isSortedSetMember(set, tid); + if (shared) { + return; + } + await Promise.all([ Topics.events.log(tid, { type: 'share', uid: uid }), - db.sortedSetAdd(`uid:${uid}:shares`, timestamp, tid), + db.sortedSetAdd(set, timestamp, tid), ]); }; };