diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index 2499f45..fc66bcd 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -459,11 +459,24 @@ export class ConversationsHelper { } }); + // Get the list of users to notify after the update + const listToNotify = (await DatabaseHelper.Query({ + table: USERS_TABLE, + where: { + conv_id: message.convID, + saw_last_message: 1, + following: 1 + }, + customWhere: "user_id != ?", + customWhereArgs: [message.userID.toString()] + })).map((f) => f.user_id); + // Mark all the user of the conversations as unread, except current user await DatabaseHelper.UpdateRows({ table: USERS_TABLE, where: { - conv_id: message.convID + conv_id: message.convID, + saw_last_message: 1 }, customWhere: "user_id != ?", customWhereArgs: [message.userID.toString()], @@ -472,6 +485,10 @@ export class ConversationsHelper { } }); + // Send the notification to all the other users + await EventsHelper.Emit("updated_number_unread_conversations", { + usersID: listToNotify + }) } /**