diff --git a/src/controllers/UserWebSocketActions.ts b/src/controllers/UserWebSocketActions.ts index 3ae7990..10311c7 100644 --- a/src/controllers/UserWebSocketActions.ts +++ b/src/controllers/UserWebSocketActions.ts @@ -87,7 +87,7 @@ export class UserWebSocketActions { continue; // Notify user - UserWebSocketController.Send(userID, "", new WsMessage({ + UserWebSocketController.Send(userID, new WsMessage({ title: "number_notifs", id: "", data: await NotificationsHelper.CountUnread(userID) @@ -108,7 +108,7 @@ export class UserWebSocketActions { continue; // Notify user - UserWebSocketController.Send(userID, "", new WsMessage({ + UserWebSocketController.Send(userID, new WsMessage({ title: "number_unread_conversations", id: "", data: await ConversationsHelper.CountUnreadForUser(userID) diff --git a/src/controllers/UserWebSocketController.ts b/src/controllers/UserWebSocketController.ts index 0bf4066..f995600 100644 --- a/src/controllers/UserWebSocketController.ts +++ b/src/controllers/UserWebSocketController.ts @@ -212,14 +212,10 @@ export class UserWebSocketController { * Send a message to a socket * * @param userID Target user ID - * @param socketID Target socket ID (if null the message is sent to - * all the active sockets of the user) * @param message The message to send */ - public static Send(userID: number, socketID: string, message: WsMessage) { - for(const entry of this.active_clients.filter( - (e) => e.userID == userID - && (socketID.length == 0 || e.socketID == socketID))) + public static Send(userID: number, message: WsMessage) { + for(const entry of this.active_clients.filter((e) => e.userID == userID)) { this.SendToClient(entry, message); } diff --git a/src/entities/WebSocketRequestHandler.ts b/src/entities/WebSocketRequestHandler.ts index 1d364fc..b6f22d8 100644 --- a/src/entities/WebSocketRequestHandler.ts +++ b/src/entities/WebSocketRequestHandler.ts @@ -56,7 +56,7 @@ export class UserWebSocketRequestsHandler extends BaseRequestsHandler { throw new Error("Trying to send a response to a request to which a response has already been sent!") // Send the response - UserWebSocketController.Send(this.wsClient.userID, this.wsClient.socketID, new WsMessage({ + UserWebSocketController.SendToClient(this.wsClient, new WsMessage({ title: title, data: data, id: this.req.id