Skip to content

Node.js based forum software built for the modern web

fix: ignore subsequent shares of the same topic by that user

Julian Lamd734ce4911d4
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),
]);
};
};