1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 00:25:17 +00:00

Notify through websocket new number of notifications

This commit is contained in:
2020-03-30 15:37:36 +02:00
parent d18914066b
commit 9816caf4db
3 changed files with 73 additions and 2 deletions

View File

@ -13,11 +13,17 @@ export interface DestroyedLoginTokensEvent {
client: APIClient
}
// When some user might have an updated number of notifications
export interface UpdatedNotificationsNumberEvent {
usersID: number[]
}
/**
* Global map of all possible events
*/
export interface EventsMap {
"destroyed_login_tokens": DestroyedLoginTokensEvent
"destroyed_login_tokens": DestroyedLoginTokensEvent,
"updated_number_notifications": UpdatedNotificationsNumberEvent,
}
export class EventsHelper {

View File

@ -6,6 +6,7 @@ import { PostPageKind, PostVisibilityLevel } from "../entities/Post";
import { FriendsHelper } from "./FriendsHelper";
import { GroupsHelper } from "./GroupsHelper";
import { GroupMembershipLevels } from "../entities/GroupMember";
import { EventsHelper } from "./EventsHelper";
/**
* Notifications helper
@ -308,6 +309,9 @@ export class NotificationsHelper {
NOTIFICATIONS_TABLE,
this.NotifToDB(n, true)
)
// Trigger notify system
await EventsHelper.Emit("updated_number_notifications", {usersID: [n.destUserID]});
}
/**