1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-12-27 22:18:52 +00:00

Propagate the deletion of a conversation message

This commit is contained in:
Pierre HUBERT 2020-04-03 08:56:39 +02:00
parent 5503d1af0b
commit 2465b0c1ac
3 changed files with 26 additions and 1 deletions

View File

@ -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))

View File

@ -709,6 +709,11 @@ export class ConversationsHelper {
ID: m.id
}
)
// Notify system
await EventsHelper.Emit("conv_message_deleted", {
message: m
})
}
/**

View File

@ -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,