From 9bc24c78437cb34fbd30312858739a6db8e44d3a Mon Sep 17 00:00:00 2001 From: WofWca Date: Mon, 22 Sep 2025 18:16:09 +0400 Subject: [PATCH] api: add `chat_id` to all call events --- deltachat-jsonrpc/src/api/types/events.rs | 18 ++++++++++++++++-- src/calls.rs | 7 +++++++ src/calls/calls_tests.rs | 1 + src/events/payload.rs | 8 ++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/deltachat-jsonrpc/src/api/types/events.rs b/deltachat-jsonrpc/src/api/types/events.rs index 1028522c56..320ca57d3b 100644 --- a/deltachat-jsonrpc/src/api/types/events.rs +++ b/deltachat-jsonrpc/src/api/types/events.rs @@ -425,6 +425,8 @@ pub enum EventType { IncomingCall { /// ID of the info message referring to the call. msg_id: u32, + /// ID of the chat which the message belongs to. + chat_id: u32, /// User-defined info as passed to place_outgoing_call() place_call_info: String, /// True if incoming call is a video call. @@ -436,12 +438,16 @@ pub enum EventType { IncomingCallAccepted { /// ID of the info message referring to the call. msg_id: u32, + /// ID of the chat which the message belongs to. + chat_id: u32, }, /// Outgoing call accepted. OutgoingCallAccepted { /// ID of the info message referring to the call. msg_id: u32, + /// ID of the chat which the message belongs to. + chat_id: u32, /// User-defined info passed to dc_accept_incoming_call( accept_call_info: String, }, @@ -450,6 +456,8 @@ pub enum EventType { CallEnded { /// ID of the info message referring to the call. msg_id: u32, + /// ID of the chat which the message belongs to. + chat_id: u32, }, } @@ -605,25 +613,31 @@ impl From for EventType { CoreEventType::AccountsItemChanged => AccountsItemChanged, CoreEventType::IncomingCall { msg_id, + chat_id, place_call_info, has_video, } => IncomingCall { msg_id: msg_id.to_u32(), + chat_id: chat_id.to_u32(), place_call_info, has_video, }, - CoreEventType::IncomingCallAccepted { msg_id } => IncomingCallAccepted { + CoreEventType::IncomingCallAccepted { msg_id, chat_id } => IncomingCallAccepted { msg_id: msg_id.to_u32(), + chat_id: chat_id.to_u32(), }, CoreEventType::OutgoingCallAccepted { msg_id, + chat_id, accept_call_info, } => OutgoingCallAccepted { msg_id: msg_id.to_u32(), + chat_id: chat_id.to_u32(), accept_call_info, }, - CoreEventType::CallEnded { msg_id } => CallEnded { + CoreEventType::CallEnded { msg_id, chat_id } => CallEnded { msg_id: msg_id.to_u32(), + chat_id: chat_id.to_u32(), }, #[allow(unreachable_patterns)] #[cfg(test)] diff --git a/src/calls.rs b/src/calls.rs index 890aa6d186..c579a68cb8 100644 --- a/src/calls.rs +++ b/src/calls.rs @@ -197,6 +197,7 @@ impl Context { msg.id = send_msg(self, call.msg.chat_id, &mut msg).await?; self.emit_event(EventType::IncomingCallAccepted { msg_id: call.msg.id, + chat_id: call.msg.chat_id, }); self.emit_msgs_changed(call.msg.chat_id, call_id); Ok(()) @@ -233,6 +234,7 @@ impl Context { self.emit_event(EventType::CallEnded { msg_id: call.msg.id, + chat_id: call.msg.chat_id, }); self.emit_msgs_changed(call.msg.chat_id, call_id); Ok(()) @@ -255,6 +257,7 @@ impl Context { context.emit_msgs_changed(call.msg.chat_id, call_id); context.emit_event(EventType::CallEnded { msg_id: call.msg.id, + chat_id: call.msg.chat_id, }); } Ok(()) @@ -285,6 +288,7 @@ impl Context { }; self.emit_event(EventType::IncomingCall { msg_id: call.msg.id, + chat_id: call.msg.chat_id, place_call_info: call.place_call_info.to_string(), has_video, }); @@ -313,6 +317,7 @@ impl Context { if call.is_incoming() { self.emit_event(EventType::IncomingCallAccepted { msg_id: call.msg.id, + chat_id: call.msg.chat_id, }); } else { let accept_call_info = mime_message @@ -320,6 +325,7 @@ impl Context { .unwrap_or_default(); self.emit_event(EventType::OutgoingCallAccepted { msg_id: call.msg.id, + chat_id: call.msg.chat_id, accept_call_info: accept_call_info.to_string(), }); } @@ -355,6 +361,7 @@ impl Context { self.emit_msgs_changed(call.msg.chat_id, call_id); self.emit_event(EventType::CallEnded { msg_id: call.msg.id, + chat_id: call.msg.chat_id, }); } _ => {} diff --git a/src/calls/calls_tests.rs b/src/calls/calls_tests.rs index 321e3b62ad..eeda7efc77 100644 --- a/src/calls/calls_tests.rs +++ b/src/calls/calls_tests.rs @@ -131,6 +131,7 @@ async fn accept_call() -> Result { ev, EventType::OutgoingCallAccepted { msg_id: alice2_call.id, + chat_id: alice2_call.chat_id, accept_call_info: ACCEPT_INFO.to_string() } ); diff --git a/src/events/payload.rs b/src/events/payload.rs index 83e8fa9238..68d6b6f34e 100644 --- a/src/events/payload.rs +++ b/src/events/payload.rs @@ -384,6 +384,8 @@ pub enum EventType { IncomingCall { /// ID of the message referring to the call. msg_id: MsgId, + /// ID of the chat which the message belongs to. + chat_id: ChatId, /// User-defined info as passed to place_outgoing_call() place_call_info: String, /// True if incoming call is a video call. @@ -394,12 +396,16 @@ pub enum EventType { IncomingCallAccepted { /// ID of the message referring to the call. msg_id: MsgId, + /// ID of the chat which the message belongs to. + chat_id: ChatId, }, /// Outgoing call accepted. OutgoingCallAccepted { /// ID of the message referring to the call. msg_id: MsgId, + /// ID of the chat which the message belongs to. + chat_id: ChatId, /// User-defined info as passed to accept_incoming_call() accept_call_info: String, }, @@ -408,6 +414,8 @@ pub enum EventType { CallEnded { /// ID of the message referring to the call. msg_id: MsgId, + /// ID of the chat which the message belongs to. + chat_id: ChatId, }, /// Event for using in tests, e.g. as a fence between normally generated events.