mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-24 10:23:28 +00:00
Turn WsMessage into an object
This commit is contained in:
@ -11,6 +11,7 @@ import { randomStr } from '../utils/CryptUtils';
|
||||
import { EventsHelper } from '../helpers/EventsHelper';
|
||||
import { NotificationsHelper } from '../helpers/NotificationsHelper';
|
||||
import { ConversationsHelper } from '../helpers/ConversationsHelper';
|
||||
import { WsMessage } from '../entities/WsMessage';
|
||||
|
||||
interface PendingRequests {
|
||||
time: number,
|
||||
@ -26,12 +27,6 @@ export interface ActiveClient {
|
||||
ws: ws
|
||||
}
|
||||
|
||||
export interface WsMessage {
|
||||
id: string,
|
||||
title: string,
|
||||
data: any
|
||||
}
|
||||
|
||||
// Tokens are valid only 10 seconds after they are generated
|
||||
const TOKENS_DURATION = 10
|
||||
const TOKEN_LENGTH = 20
|
||||
@ -201,11 +196,11 @@ export class UserWebSocketController {
|
||||
continue;
|
||||
|
||||
// Notify user
|
||||
this.Send(userID, "", {
|
||||
this.Send(userID, "", new WsMessage({
|
||||
title: "number_notifs",
|
||||
id: "",
|
||||
data: await NotificationsHelper.CountUnread(userID)
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
@ -222,11 +217,11 @@ export class UserWebSocketController {
|
||||
continue;
|
||||
|
||||
// Notify user
|
||||
this.Send(userID, "", {
|
||||
this.Send(userID, "", new WsMessage({
|
||||
title: "number_unread_conversations",
|
||||
id: "",
|
||||
data: await ConversationsHelper.CountUnreadForUser(userID)
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user