mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-19 16:15:16 +00:00
Send new number unread conversations for user
This commit is contained in:
@ -4,6 +4,7 @@ import { time } from "../utils/DateUtils";
|
||||
import { ConversationMessage, BaseConversationMessage } from "../entities/ConversationMessage";
|
||||
import { UnreadConversation } from "../entities/UnreadConversation";
|
||||
import { existsSync, unlinkSync } from "fs";
|
||||
import { EventsHelper } from "./EventsHelper";
|
||||
|
||||
/**
|
||||
* Conversations helper
|
||||
@ -407,7 +408,7 @@ export class ConversationsHelper {
|
||||
* @param userID Target user ID
|
||||
*/
|
||||
public static async MarkUserSeen(convID: number, userID: number) {
|
||||
await DatabaseHelper.UpdateRows({
|
||||
const count = await DatabaseHelper.UpdateRows({
|
||||
table: USERS_TABLE,
|
||||
where: {
|
||||
conv_id: convID,
|
||||
@ -417,6 +418,12 @@ export class ConversationsHelper {
|
||||
saw_last_message: 1
|
||||
}
|
||||
});
|
||||
|
||||
// Send an event if required
|
||||
if(count > 0)
|
||||
await EventsHelper.Emit("updated_number_unread_conversations", {
|
||||
usersID: [userID]
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,12 +18,18 @@ export interface UpdatedNotificationsNumberEvent {
|
||||
usersID: number[]
|
||||
}
|
||||
|
||||
// When some users have an updated number of unread conversations
|
||||
export interface UpdateNumberUnreadConversations {
|
||||
usersID: number[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Global map of all possible events
|
||||
*/
|
||||
export interface EventsMap {
|
||||
"destroyed_login_tokens": DestroyedLoginTokensEvent,
|
||||
"updated_number_notifications": UpdatedNotificationsNumberEvent,
|
||||
"updated_number_unread_conversations": UpdateNumberUnreadConversations
|
||||
}
|
||||
|
||||
export class EventsHelper {
|
||||
|
Reference in New Issue
Block a user