1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-25 06:49:23 +00:00

Notify websockets when the number of unread notifications decrease

This commit is contained in:
Pierre HUBERT 2020-03-30 15:42:41 +02:00
parent 9816caf4db
commit 0fbc9d9068

View File

@ -323,8 +323,19 @@ export class NotificationsHelper {
// Delete a specific notification // Delete a specific notification
const cond = n.hasId ? {id: n.id} : this.NotifToDB(n, false); const cond = n.hasId ? {id: n.id} : this.NotifToDB(n, false);
// Check for affected users
const users = new Set<number>();
(await DatabaseHelper.Query({
table: NOTIFICATIONS_TABLE,
where: cond,
fields: ["dest_user_id"]
})).forEach((row) => users.add(row.dest_user_id))
// Delete notifications // Delete notifications
await DatabaseHelper.DeleteRows(NOTIFICATIONS_TABLE, cond); await DatabaseHelper.DeleteRows(NOTIFICATIONS_TABLE, cond);
// Trigger notifications system
await EventsHelper.Emit("updated_number_notifications", {usersID: [...users]});
} }
/** /**