|
2 | 2 | //! |
3 | 3 | //! Internally, calls are bound a user-visible message initializing the call. |
4 | 4 | //! This means, the "Call ID" is a "Message ID" - similar to Webxdc IDs. |
| 5 | +use crate::chat::ChatIdBlocked; |
5 | 6 | use crate::chat::{Chat, ChatId, send_msg}; |
6 | | -use crate::constants::Chattype; |
| 7 | +use crate::constants::{Blocked, Chattype}; |
7 | 8 | use crate::contact::ContactId; |
8 | 9 | use crate::context::Context; |
9 | 10 | use crate::events::EventType; |
@@ -345,12 +346,27 @@ impl Context { |
345 | 346 | false |
346 | 347 | } |
347 | 348 | }; |
348 | | - self.emit_event(EventType::IncomingCall { |
349 | | - msg_id: call.msg.id, |
350 | | - chat_id: call.msg.chat_id, |
351 | | - place_call_info: call.place_call_info.to_string(), |
352 | | - has_video, |
353 | | - }); |
| 349 | + if let Some(chat_id_blocked) = |
| 350 | + ChatIdBlocked::lookup_by_contact(self, from_id).await? |
| 351 | + { |
| 352 | + match chat_id_blocked.blocked { |
| 353 | + Blocked::Not => { |
| 354 | + self.emit_event(EventType::IncomingCall { |
| 355 | + msg_id: call.msg.id, |
| 356 | + chat_id: call.msg.chat_id, |
| 357 | + place_call_info: call.place_call_info.to_string(), |
| 358 | + has_video, |
| 359 | + }); |
| 360 | + } |
| 361 | + Blocked::Yes | Blocked::Request => { |
| 362 | + // Do not notify about incoming calls |
| 363 | + // from contact requests and blocked contacts. |
| 364 | + // |
| 365 | + // User can still access the call and accept it |
| 366 | + // via the chat in case of contact requests. |
| 367 | + } |
| 368 | + } |
| 369 | + } |
354 | 370 | let wait = call.remaining_ring_seconds(); |
355 | 371 | task::spawn(Context::emit_end_call_if_unaccepted( |
356 | 372 | self.clone(), |
|
0 commit comments