Skip to content

Commit 1b1757e

Browse files
authored
api: add chat_id to all call events (#7216)
1 parent d8950fb commit 1b1757e

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

deltachat-jsonrpc/src/api/types/events.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ pub enum EventType {
425425
IncomingCall {
426426
/// ID of the info message referring to the call.
427427
msg_id: u32,
428+
/// ID of the chat which the message belongs to.
429+
chat_id: u32,
428430
/// User-defined info as passed to place_outgoing_call()
429431
place_call_info: String,
430432
/// True if incoming call is a video call.
@@ -436,12 +438,16 @@ pub enum EventType {
436438
IncomingCallAccepted {
437439
/// ID of the info message referring to the call.
438440
msg_id: u32,
441+
/// ID of the chat which the message belongs to.
442+
chat_id: u32,
439443
},
440444

441445
/// Outgoing call accepted.
442446
OutgoingCallAccepted {
443447
/// ID of the info message referring to the call.
444448
msg_id: u32,
449+
/// ID of the chat which the message belongs to.
450+
chat_id: u32,
445451
/// User-defined info passed to dc_accept_incoming_call(
446452
accept_call_info: String,
447453
},
@@ -450,6 +456,8 @@ pub enum EventType {
450456
CallEnded {
451457
/// ID of the info message referring to the call.
452458
msg_id: u32,
459+
/// ID of the chat which the message belongs to.
460+
chat_id: u32,
453461
},
454462
}
455463

@@ -607,25 +615,31 @@ impl From<CoreEventType> for EventType {
607615
CoreEventType::AccountsItemChanged => AccountsItemChanged,
608616
CoreEventType::IncomingCall {
609617
msg_id,
618+
chat_id,
610619
place_call_info,
611620
has_video,
612621
} => IncomingCall {
613622
msg_id: msg_id.to_u32(),
623+
chat_id: chat_id.to_u32(),
614624
place_call_info,
615625
has_video,
616626
},
617-
CoreEventType::IncomingCallAccepted { msg_id } => IncomingCallAccepted {
627+
CoreEventType::IncomingCallAccepted { msg_id, chat_id } => IncomingCallAccepted {
618628
msg_id: msg_id.to_u32(),
629+
chat_id: chat_id.to_u32(),
619630
},
620631
CoreEventType::OutgoingCallAccepted {
621632
msg_id,
633+
chat_id,
622634
accept_call_info,
623635
} => OutgoingCallAccepted {
624636
msg_id: msg_id.to_u32(),
637+
chat_id: chat_id.to_u32(),
625638
accept_call_info,
626639
},
627-
CoreEventType::CallEnded { msg_id } => CallEnded {
640+
CoreEventType::CallEnded { msg_id, chat_id } => CallEnded {
628641
msg_id: msg_id.to_u32(),
642+
chat_id: chat_id.to_u32(),
629643
},
630644
#[allow(unreachable_patterns)]
631645
#[cfg(test)]

src/calls.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ impl Context {
236236
msg.id = send_msg(self, call.msg.chat_id, &mut msg).await?;
237237
self.emit_event(EventType::IncomingCallAccepted {
238238
msg_id: call.msg.id,
239+
chat_id: call.msg.chat_id,
239240
});
240241
self.emit_msgs_changed(call.msg.chat_id, call_id);
241242
Ok(())
@@ -274,6 +275,7 @@ impl Context {
274275

275276
self.emit_event(EventType::CallEnded {
276277
msg_id: call.msg.id,
278+
chat_id: call.msg.chat_id,
277279
});
278280
self.emit_msgs_changed(call.msg.chat_id, call_id);
279281
Ok(())
@@ -297,6 +299,7 @@ impl Context {
297299
context.emit_msgs_changed(call.msg.chat_id, call_id);
298300
context.emit_event(EventType::CallEnded {
299301
msg_id: call.msg.id,
302+
chat_id: call.msg.chat_id,
300303
});
301304
}
302305
Ok(())
@@ -327,6 +330,7 @@ impl Context {
327330
};
328331
self.emit_event(EventType::IncomingCall {
329332
msg_id: call.msg.id,
333+
chat_id: call.msg.chat_id,
330334
place_call_info: call.place_call_info.to_string(),
331335
has_video,
332336
});
@@ -355,13 +359,15 @@ impl Context {
355359
if call.is_incoming() {
356360
self.emit_event(EventType::IncomingCallAccepted {
357361
msg_id: call.msg.id,
362+
chat_id: call.msg.chat_id,
358363
});
359364
} else {
360365
let accept_call_info = mime_message
361366
.get_header(HeaderDef::ChatWebrtcAccepted)
362367
.unwrap_or_default();
363368
self.emit_event(EventType::OutgoingCallAccepted {
364369
msg_id: call.msg.id,
370+
chat_id: call.msg.chat_id,
365371
accept_call_info: accept_call_info.to_string(),
366372
});
367373
}
@@ -401,6 +407,7 @@ impl Context {
401407
self.emit_msgs_changed(call.msg.chat_id, call_id);
402408
self.emit_event(EventType::CallEnded {
403409
msg_id: call.msg.id,
410+
chat_id: call.msg.chat_id,
404411
});
405412
}
406413
_ => {}

src/calls/calls_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ async fn accept_call() -> Result<CallSetup> {
135135
ev,
136136
EventType::OutgoingCallAccepted {
137137
msg_id: alice_call.id,
138+
chat_id: alice_call.chat_id,
138139
accept_call_info: ACCEPT_INFO.to_string()
139140
}
140141
);

src/events/payload.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ pub enum EventType {
383383
IncomingCall {
384384
/// ID of the message referring to the call.
385385
msg_id: MsgId,
386+
/// ID of the chat which the message belongs to.
387+
chat_id: ChatId,
386388
/// User-defined info as passed to place_outgoing_call()
387389
place_call_info: String,
388390
/// True if incoming call is a video call.
@@ -393,12 +395,16 @@ pub enum EventType {
393395
IncomingCallAccepted {
394396
/// ID of the message referring to the call.
395397
msg_id: MsgId,
398+
/// ID of the chat which the message belongs to.
399+
chat_id: ChatId,
396400
},
397401

398402
/// Outgoing call accepted.
399403
OutgoingCallAccepted {
400404
/// ID of the message referring to the call.
401405
msg_id: MsgId,
406+
/// ID of the chat which the message belongs to.
407+
chat_id: ChatId,
402408
/// User-defined info as passed to accept_incoming_call()
403409
accept_call_info: String,
404410
},
@@ -407,6 +413,8 @@ pub enum EventType {
407413
CallEnded {
408414
/// ID of the message referring to the call.
409415
msg_id: MsgId,
416+
/// ID of the chat which the message belongs to.
417+
chat_id: ChatId,
410418
},
411419

412420
/// Event for using in tests, e.g. as a fence between normally generated events.

0 commit comments

Comments
 (0)