mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
Propagate an event when deleting a conversation
This commit is contained in:
parent
4776207ce8
commit
0d8a514392
@ -544,6 +544,26 @@ pub fn handle_event(e: &events_helper::Event) -> Res {
|
|||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Event::DeletedConversation(conv_id) => {
|
||||||
|
// Notify users
|
||||||
|
user_ws_controller::send_message_to_specific_connections(
|
||||||
|
|f| f.conversations.contains(conv_id),
|
||||||
|
|_| UserWsMessage::no_id_message("deleted_conversation", conv_id.id()),
|
||||||
|
None::<fn(&_) -> _>,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Disconnect user from conversation
|
||||||
|
user_ws_controller::foreach_connection(|f| {
|
||||||
|
if f.conversations.contains(conv_id) {
|
||||||
|
f.clone().replace(|w| {
|
||||||
|
w.conversations.remove(conv_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,6 +453,9 @@ pub fn delete_conversation(conv: &Conversation) -> ResultBoxError<()> {
|
|||||||
.cond_conv_id("id", conv.id)
|
.cond_conv_id("id", conv.id)
|
||||||
.exec()?;
|
.exec()?;
|
||||||
|
|
||||||
|
// Propagate information
|
||||||
|
events_helper::propagate_event(&Event::DeletedConversation(conv.id))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,9 @@ pub enum Event<'a> {
|
|||||||
/// Removed a user from a conversation
|
/// Removed a user from a conversation
|
||||||
RemovedUserFromConversation(&'a UserID, ConvID),
|
RemovedUserFromConversation(&'a UserID, ConvID),
|
||||||
|
|
||||||
|
/// Delete a conversation
|
||||||
|
DeletedConversation(ConvID),
|
||||||
|
|
||||||
/// Created a new comment
|
/// Created a new comment
|
||||||
NewComment(&'a Comment),
|
NewComment(&'a Comment),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user