Skip to content

Commit b812d0a

Browse files
committed
fix: do not notify about incoming calls for contact requests and blocked contacts
1 parent e8a4c92 commit b812d0a

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/calls.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
//!
33
//! Internally, calls are bound a user-visible message initializing the call.
44
//! This means, the "Call ID" is a "Message ID" - similar to Webxdc IDs.
5+
use crate::chat::ChatIdBlocked;
56
use crate::chat::{Chat, ChatId, send_msg};
6-
use crate::constants::Chattype;
7+
use crate::constants::{Blocked, Chattype};
78
use crate::contact::ContactId;
89
use crate::context::Context;
910
use crate::events::EventType;
@@ -345,12 +346,27 @@ impl Context {
345346
false
346347
}
347348
};
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+
}
354370
let wait = call.remaining_ring_seconds();
355371
task::spawn(Context::emit_end_call_if_unaccepted(
356372
self.clone(),

0 commit comments

Comments
 (0)