diff --git a/src/controllers/UserWebSocketActions.ts b/src/controllers/UserWebSocketActions.ts index d75d28f..232abcd 100644 --- a/src/controllers/UserWebSocketActions.ts +++ b/src/controllers/UserWebSocketActions.ts @@ -144,6 +144,19 @@ export class UserWebSocketActions { ) } + /** + * Propagate the deletion of a conversation message + * + * @param msg Message ID + */ + public static async DeletedConversationMessage(msg: ConversationMessage) { + await UserWebSocketController.SendToSpecifcClients( + (e) => e.registeredConversations.has(msg.convID), + () => WsMessage.NoIDMessage("deleted_conv_message", ConversationsController.ConversationMessageToAPI(msg)) + ) + } + + /** * Propagate the creation of a new comment * @@ -192,9 +205,10 @@ EventsHelper.Listen("updated_number_notifications", async (e) => await UserWebSo // When we get a new number of unread conversations EventsHelper.Listen("updated_number_unread_conversations", async (e) => await UserWebSocketActions.SendNewUnreadConversationsCount(e.usersID)); -// When a new message is sent / updated +// When a new message is sent / updated / deleted EventsHelper.Listen("sent_conversation_message", async (e) => await UserWebSocketActions.SentNewConversationMessage(e.msg)); EventsHelper.Listen("conv_message_updated", async (e) => await UserWebSocketActions.UpdatedConversationMessage(e.msgId)); +EventsHelper.Listen("conv_message_deleted", async (e) => await UserWebSocketActions.DeletedConversationMessage(e.message)); // When a comment is created / updated / deleted EventsHelper.Listen("comment_created", async (e) => await UserWebSocketActions.CreatedNewComment(e.comment)) diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index c0f5b93..e2f19fa 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -709,6 +709,11 @@ export class ConversationsHelper { ID: m.id } ) + + // Notify system + await EventsHelper.Emit("conv_message_deleted", { + message: m + }) } /** diff --git a/src/helpers/EventsHelper.ts b/src/helpers/EventsHelper.ts index e5f3beb..1659c19 100644 --- a/src/helpers/EventsHelper.ts +++ b/src/helpers/EventsHelper.ts @@ -34,6 +34,11 @@ export interface UpdatedConversationMessageEvent { msgId: number } +// When a conversation message was deleted +export interface DeletedConversationMessageEvent { + message: ConversationMessage +} + // When a comment is created export interface CommentCreatedEvent { comment: Comment @@ -58,6 +63,7 @@ export interface EventsMap { "updated_number_unread_conversations": UpdateNumberUnreadConversationsEvent, "sent_conversation_message": SentNewConversationMessageEvent, "conv_message_updated": UpdatedConversationMessageEvent, + "conv_message_deleted": DeletedConversationMessageEvent, "comment_created": CommentCreatedEvent, "comment_updated": CommentUpdatedEvent, "comment_deleted": CommentDeletedEvent,