Skip to content

Commit 8091094

Browse files
robintownpoljar
authored andcommitted
refactor(room): Remove methods for sending call notifications
As noted in the changelog entry, the event type they send is outdated, and Client is not actually supposed to be able to join MatrixRTC sessions at this time. A MatrixRTC client implementation which actually participates in sessions should be able to send these notifications without the SDK's help.
1 parent feadfde commit 8091094

File tree

5 files changed

+9
-326
lines changed

5 files changed

+9
-326
lines changed

bindings/matrix-sdk-ffi/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ All notable changes to this project will be documented in this file.
6464
calling `Client::login_with_qr_code`. ([#5388](https://github.com/matrix-org/matrix-rust-sdk/pull/5388))
6565
- The MSRV has been bumped to Rust 1.88.
6666
([#5431](https://github.com/matrix-org/matrix-rust-sdk/pull/5431))
67+
- `Room::send_call_notification` and `Room::send_call_notification_if_needed` have been removed, since the event type they send is outdated, and `Client` is not actually supposed to be able to join MatrixRTC sessions (yet). In practice, users of these methods probably already rely on another MatrixRTC implementation to participate in sessions, and such an implementation should be capable of sending notifications itself.
6768

6869
## [0.13.0] - 2025-07-10
6970

bindings/matrix-sdk-ffi/src/room/mod.rs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::{
4444
live_location_share::{LastLocation, LiveLocationShare},
4545
room_member::{RoomMember, RoomMemberWithSenderInfo},
4646
room_preview::RoomPreview,
47-
ruma::{ImageInfo, LocationContent, Mentions, NotifyType},
47+
ruma::{ImageInfo, LocationContent},
4848
runtime::get_runtime_handle,
4949
timeline::{
5050
configuration::{TimelineConfiguration, TimelineFilter},
@@ -720,53 +720,6 @@ impl Room {
720720
Ok(self.inner.matrix_to_event_permalink(event_id).await?.to_string())
721721
}
722722

723-
/// This will only send a call notification event if appropriate.
724-
///
725-
/// This function is supposed to be called whenever the user creates a room
726-
/// call. It will send a `m.call.notify` event if:
727-
/// - there is not yet a running call.
728-
///
729-
/// It will configure the notify type: ring or notify based on:
730-
/// - is this a DM room -> ring
731-
/// - is this a group with more than one other member -> notify
732-
///
733-
/// Returns:
734-
/// - `Ok(true)` if the event was successfully sent.
735-
/// - `Ok(false)` if we didn't send it because it was unnecessary.
736-
/// - `Err(_)` if sending the event failed.
737-
pub async fn send_call_notification_if_needed(&self) -> Result<bool, ClientError> {
738-
Ok(self.inner.send_call_notification_if_needed().await?)
739-
}
740-
741-
/// Send a call notification event in the current room.
742-
///
743-
/// This is only supposed to be used in **custom** situations where the user
744-
/// explicitly chooses to send a `m.call.notify` event to invite/notify
745-
/// someone explicitly in unusual conditions. The default should be to
746-
/// use `send_call_notification_if_necessary` just before a new room call is
747-
/// created/joined.
748-
///
749-
/// One example could be that the UI allows to start a call with a subset of
750-
/// users of the room members first. And then later on the user can
751-
/// invite more users to the call.
752-
pub async fn send_call_notification(
753-
&self,
754-
call_id: String,
755-
application: RtcApplicationType,
756-
notify_type: NotifyType,
757-
mentions: Mentions,
758-
) -> Result<(), ClientError> {
759-
self.inner
760-
.send_call_notification(
761-
call_id,
762-
application.into(),
763-
notify_type.into(),
764-
mentions.into(),
765-
)
766-
.await?;
767-
Ok(())
768-
}
769-
770723
/// Returns whether the send queue for that particular room is enabled or
771724
/// not.
772725
pub fn is_send_queue_enabled(&self) -> bool {

crates/matrix-sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ All notable changes to this project will be documented in this file.
5050
([#5337](https://github.com/matrix-org/matrix-rust-sdk/pull/5337))
5151
- [**breaking**] The MSRV has been bumped to Rust 1.88.
5252
([#5431](https://github.com/matrix-org/matrix-rust-sdk/pull/5431))
53+
- [**breaking**] `Room::send_call_notification` and `Room::send_call_notification_if_needed` have been removed, since the event type they send is outdated, and `Client` is not actually supposed to be able to join MatrixRTC sessions (yet). In practice, users of these methods probably already rely on another MatrixRTC implementation to participate in sessions, and such an implementation should be capable of sending notifications itself.
5354

5455
### Bugfix
5556

crates/matrix-sdk/src/room/mod.rs

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ use ruma::{
8787
events::{
8888
beacon::BeaconEventContent,
8989
beacon_info::BeaconInfoEventContent,
90-
call::notify::{ApplicationType, CallNotifyEventContent, NotifyType},
9190
direct::DirectEventContent,
9291
marked_unread::MarkedUnreadEventContent,
9392
receipt::{Receipt, ReceiptThread, ReceiptType},
@@ -3272,59 +3271,6 @@ impl Room {
32723271
self.client.event_cache().for_room(self.room_id()).await
32733272
}
32743273

3275-
/// This will only send a call notification event if appropriate.
3276-
///
3277-
/// This function is supposed to be called whenever the user creates a room
3278-
/// call. It will send a `m.call.notify` event if:
3279-
/// - there is not yet a running call.
3280-
///
3281-
/// It will configure the notify type: ring or notify based on:
3282-
/// - is this a DM room -> ring
3283-
/// - is this a group with more than one other member -> notify
3284-
///
3285-
/// Returns:
3286-
/// - `Ok(true)` if the event was successfully sent.
3287-
/// - `Ok(false)` if we didn't send it because it was unnecessary.
3288-
/// - `Err(_)` if sending the event failed.
3289-
pub async fn send_call_notification_if_needed(&self) -> Result<bool> {
3290-
debug!("Sending call notification for room {} if needed", self.inner.room_id());
3291-
3292-
if self.has_active_room_call() {
3293-
warn!("Room {} has active room call, not sending a new notify event.", self.room_id());
3294-
return Ok(false);
3295-
}
3296-
3297-
let can_user_trigger_room_notification =
3298-
self.power_levels().await?.user_can_trigger_room_notification(self.own_user_id());
3299-
3300-
if !can_user_trigger_room_notification {
3301-
warn!(
3302-
"User can't send notifications to everyone in the room {}. \
3303-
Not sending a new notify event.",
3304-
self.room_id()
3305-
);
3306-
return Ok(false);
3307-
}
3308-
3309-
let notify_type = if self.is_direct().await.unwrap_or(false) {
3310-
NotifyType::Ring
3311-
} else {
3312-
NotifyType::Notify
3313-
};
3314-
3315-
debug!("Sending `m.call.notify` event with notify type: {notify_type:?}");
3316-
3317-
self.send_call_notification(
3318-
self.room_id().to_string().to_owned(),
3319-
ApplicationType::Call,
3320-
notify_type,
3321-
Mentions::with_room_mention(),
3322-
)
3323-
.await?;
3324-
3325-
Ok(true)
3326-
}
3327-
33283274
/// Get the beacon information event in the room for the `user_id`.
33293275
///
33303276
/// # Errors
@@ -3421,30 +3367,6 @@ impl Room {
34213367
}
34223368
}
34233369

3424-
/// Send a call notification event in the current room.
3425-
///
3426-
/// This is only supposed to be used in **custom** situations where the user
3427-
/// explicitly chooses to send a `m.call.notify` event to invite/notify
3428-
/// someone explicitly in unusual conditions. The default should be to
3429-
/// use `send_call_notification_if_needed` just before a new room call is
3430-
/// created/joined.
3431-
///
3432-
/// One example could be that the UI allows to start a call with a subset of
3433-
/// users of the room members first. And then later on the user can
3434-
/// invite more users to the call.
3435-
pub async fn send_call_notification(
3436-
&self,
3437-
call_id: String,
3438-
application: ApplicationType,
3439-
notify_type: NotifyType,
3440-
mentions: Mentions,
3441-
) -> Result<()> {
3442-
let call_notify_event_content =
3443-
CallNotifyEventContent::new(call_id, application, notify_type, mentions);
3444-
self.send(call_notify_event_content).await?;
3445-
Ok(())
3446-
}
3447-
34483370
/// Store the given `ComposerDraft` in the state store using the current
34493371
/// room id and optional thread root id as identifier.
34503372
pub async fn save_composer_draft(

0 commit comments

Comments
 (0)