refactor: topics.markAsUnreadForAll

fix fork test
This commit is contained in:
Barış Soner Uşaklı
2022-12-22 09:53:04 -05:00
parent 2144650dd5
commit d1087106e4
5 changed files with 11 additions and 10 deletions

View File

@@ -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);
}
}
};

View File

@@ -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);
};