mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-10-30 23:24:42 +00:00 
			
		
		
		
	Propagate an event when deleting a conversation
This commit is contained in:
		| @@ -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) | ||||
|         .exec()?; | ||||
|  | ||||
|     // Propagate information | ||||
|     events_helper::propagate_event(&Event::DeletedConversation(conv.id))?; | ||||
|  | ||||
|     Ok(()) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -44,6 +44,9 @@ pub enum Event<'a> { | ||||
|     /// Removed a user from a conversation | ||||
|     RemovedUserFromConversation(&'a UserID, ConvID), | ||||
|  | ||||
|     /// Delete a conversation | ||||
|     DeletedConversation(ConvID), | ||||
|  | ||||
|     /// Created a new comment | ||||
|     NewComment(&'a Comment), | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user