mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: ignore subsequent shares of the same topic by that user
This commit is contained in:
@@ -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),
|
||||
]);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user