mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-10 17:03:20 -04:00
refactor: Add extra logs to Client::send_call_notifications_if_needed
Also make it return `Result<bool>` instead of `Result<()>` so we can check if the event was sent.
This commit is contained in:
committed by
Ivan Enderlin
parent
c1ce92bf48
commit
baf6824bc4
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
### Features
|
||||
|
||||
- `Client::send_call_notification_if_needed` now returns `Result<bool>` instead of `Result<()>` so we can check if
|
||||
the event was sent.
|
||||
- Added `SendMediaUploadRequest` wrapper for `SendRequest`, which checks the size of the request to
|
||||
upload making sure it doesn't exceed the `m.upload.size` value that can be fetched through
|
||||
`Client::load_or_fetch_max_upload_size`.
|
||||
|
||||
@@ -3311,28 +3311,45 @@ impl Room {
|
||||
/// It will configure the notify type: ring or notify based on:
|
||||
/// - is this a DM room -> ring
|
||||
/// - is this a group with more than one other member -> notify
|
||||
pub async fn send_call_notification_if_needed(&self) -> Result<()> {
|
||||
///
|
||||
/// Returns:
|
||||
/// - `Ok(true)` if the event was successfully sent.
|
||||
/// - `Ok(false)` if we didn't send it because it was unnecessary.
|
||||
/// - `Err(_)` if sending the event failed.
|
||||
pub async fn send_call_notification_if_needed(&self) -> Result<bool> {
|
||||
debug!("Sending call notification for room {} if needed", self.inner.room_id());
|
||||
|
||||
if self.has_active_room_call() {
|
||||
return Ok(());
|
||||
warn!("Room {} has active room call, not sending a new notify event.", self.room_id());
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
if !self.can_user_trigger_room_notification(self.own_user_id()).await? {
|
||||
return Ok(());
|
||||
warn!(
|
||||
"User can't send notifications to everyone in the room {}. \
|
||||
Not sending a new notify event.",
|
||||
self.room_id()
|
||||
);
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let notify_type = if self.is_direct().await.unwrap_or(false) {
|
||||
NotifyType::Ring
|
||||
} else {
|
||||
NotifyType::Notify
|
||||
};
|
||||
|
||||
debug!("Sending `m.call.notify` event with notify type: {notify_type:?}");
|
||||
|
||||
self.send_call_notification(
|
||||
self.room_id().to_string().to_owned(),
|
||||
ApplicationType::Call,
|
||||
if self.is_direct().await.unwrap_or(false) {
|
||||
NotifyType::Ring
|
||||
} else {
|
||||
NotifyType::Notify
|
||||
},
|
||||
notify_type,
|
||||
Mentions::with_room_mention(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// Get the beacon information event in the room for the `user_id`.
|
||||
|
||||
Reference in New Issue
Block a user