From a4dcf49d747baeabd1a3b3420a5270ab530f2b97 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 2 Apr 2020 18:43:06 +0200 Subject: [PATCH] Send a message through websocket for updated messages --- src/controllers/UserWebSocketActions.ts | 13 ++++++++++++- src/helpers/ConversationsHelper.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/controllers/UserWebSocketActions.ts b/src/controllers/UserWebSocketActions.ts index a806e7a..5a3d2e4 100644 --- a/src/controllers/UserWebSocketActions.ts +++ b/src/controllers/UserWebSocketActions.ts @@ -143,7 +143,18 @@ export class UserWebSocketActions { * @param msgID Message ID */ public static async UpdatedConversationMessage(msgID: number) { - console.info("Update conversation message " + msgID); + const msg = await ConversationsHelper.GetSingleMessage(msgID); + + for(const client of UserWebSocketController.active_clients.filter( + e => e.registeredConversations.has(msg.convID))) { + + UserWebSocketController.SendToClient(client, new WsMessage({ + id: "", + title: "updated_conv_message", + data: ConversationsController.ConversationMessageToAPI(msg) + })) + + } } /** diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index 7740b47..c0f5b93 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -317,7 +317,7 @@ export class ConversationsHelper { * @param messageID The ID of the message to get * @throws If the message was not found */ - private static async GetSingleMessage(messageID: number) : Promise { + public static async GetSingleMessage(messageID: number) : Promise { const row = await DatabaseHelper.QueryRow({ table: MESSAGES_TABLE, where: {