refactor(socket.io): deprecate SocketModules.chats.setNotificationSetting in favour of api.chats.watch

This commit is contained in:
Julian Lam
2023-11-16 11:23:39 -05:00
parent b13c6ee431
commit 75c8cda18c
7 changed files with 94 additions and 8 deletions

View File

@@ -198,6 +198,15 @@ chatsAPI.mark = async (caller, data) => {
messaging.pushUnreadCount(caller.uid);
};
chatsAPI.watch = async (caller, { roomId, state }) => {
const inRoom = await messaging.isUserInRoom(caller.uid, roomId);
if (!inRoom) {
throw new Error('[[error:no-privileges]]');
}
await messaging.setUserNotificationSetting(caller.uid, roomId, state);
};
chatsAPI.users = async (caller, data) => {
const start = data.hasOwnProperty('start') ? data.start : 0;
const stop = start + 39;