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

This commit is contained in:
Julian Lam
2024-12-16 22:34:26 -05:00
parent cc65214de9
commit d734ce4911

View File

@@ -302,9 +302,15 @@ module.exports = function (Topics) {
}; };
topicTools.share = async function (tid, uid, timestamp = Date.now()) { 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([ await Promise.all([
Topics.events.log(tid, { type: 'share', uid: uid }), Topics.events.log(tid, { type: 'share', uid: uid }),
db.sortedSetAdd(`uid:${uid}:shares`, timestamp, tid), db.sortedSetAdd(set, timestamp, tid),
]); ]);
}; };
}; };