mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 22:35:57 +02:00
refactor: topics.markAsUnreadForAll
fix fork test
This commit is contained in:
@@ -34,7 +34,10 @@ SocketTopics.bookmark = async function (socket, data) {
|
||||
}
|
||||
const postcount = await topics.getTopicField(data.tid, 'postcount');
|
||||
if (data.index > meta.config.bookmarkThreshold && postcount > meta.config.bookmarkThreshold) {
|
||||
await topics.setUserBookmark(data.tid, socket.uid, data.index);
|
||||
const currentIndex = await db.sortedSetScore(`tid:${data.tid}:bookmarks`, socket.uid);
|
||||
if (!currentIndex || data.index > currentIndex) {
|
||||
await topics.setUserBookmark(data.tid, socket.uid, data.index);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ module.exports = function (SocketTopics) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
const isAdmin = await user.isAdministrator(socket.uid);
|
||||
const now = Date.now();
|
||||
await Promise.all(tids.map(async (tid) => {
|
||||
const topicData = await topics.getTopicFields(tid, ['tid', 'cid']);
|
||||
if (!topicData.tid) {
|
||||
@@ -65,9 +64,6 @@ module.exports = function (SocketTopics) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
await topics.markAsUnreadForAll(tid);
|
||||
await topics.updateRecent(tid, now);
|
||||
await db.sortedSetAdd(`cid:${topicData.cid}:tids:lastposttime`, now, tid);
|
||||
await topics.setTopicField(tid, 'lastposttime', now);
|
||||
}));
|
||||
topics.pushUnreadCount(socket.uid);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user