mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
mark chat room notifs read on load
This commit is contained in:
@@ -5,6 +5,7 @@ const winston = require('winston');
|
||||
const batch = require('../batch');
|
||||
const db = require('../database');
|
||||
const notifications = require('../notifications');
|
||||
const user = require('../user');
|
||||
const io = require('../socket.io');
|
||||
const plugins = require('../plugins');
|
||||
const meta = require('../meta');
|
||||
@@ -29,6 +30,17 @@ module.exports = function (Messaging) {
|
||||
return uids.map(uid => parseInt(settings[uid] || roomData.notificationSetting, 10));
|
||||
};
|
||||
|
||||
Messaging.markRoomNotificationsRead = async (uid, roomId) => {
|
||||
const chatNids = await db.getSortedSetScan({
|
||||
key: `uid:${uid}:notifications:unread`,
|
||||
match: `chat_${roomId}_*`,
|
||||
});
|
||||
if (chatNids.length) {
|
||||
await notifications.markReadMultiple(chatNids, uid);
|
||||
await user.notifications.pushCount(uid);
|
||||
}
|
||||
};
|
||||
|
||||
Messaging.notifyUsersInRoom = async (fromUid, roomId, messageObj) => {
|
||||
const isPublic = parseInt(await db.getObjectField(`chat:room:${roomId}`, 'public'), 10) === 1;
|
||||
|
||||
@@ -114,7 +126,7 @@ module.exports = function (Messaging) {
|
||||
subject: `[[email:notif.chat.subject, ${displayname}]]`,
|
||||
bodyShort: `[[notifications:new_message_from, ${displayname}]]`,
|
||||
bodyLong: messageObj.content,
|
||||
nid: `chat_${fromUid}_${roomId}`,
|
||||
nid: `chat_${roomId}_${fromUid}`,
|
||||
from: fromUid,
|
||||
path: `/chats/${messageObj.roomId}`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user