@@ -3311,28 +3311,45 @@ impl Room {
3311
3311
/// It will configure the notify type: ring or notify based on:
3312
3312
/// - is this a DM room -> ring
3313
3313
/// - is this a group with more than one other member -> notify
3314
- pub async fn send_call_notification_if_needed ( & self ) -> Result < ( ) > {
3314
+ ///
3315
+ /// Returns:
3316
+ /// - `Ok(true)` if the event was successfully sent.
3317
+ /// - `Ok(false)` if we didn't send it because it was unnecessary.
3318
+ /// - `Err(_)` if sending the event failed.
3319
+ pub async fn send_call_notification_if_needed ( & self ) -> Result < bool > {
3320
+ debug ! ( "Sending call notification for room {} if needed" , self . inner. room_id( ) ) ;
3321
+
3315
3322
if self . has_active_room_call ( ) {
3316
- return Ok ( ( ) ) ;
3323
+ warn ! ( "Room {} has active room call, not sending a new notify event." , self . room_id( ) ) ;
3324
+ return Ok ( false ) ;
3317
3325
}
3318
3326
3319
3327
if !self . can_user_trigger_room_notification ( self . own_user_id ( ) ) . await ? {
3320
- return Ok ( ( ) ) ;
3328
+ warn ! (
3329
+ "User can't send notifications to everyone in the room {}. \
3330
+ Not sending a new notify event.",
3331
+ self . room_id( )
3332
+ ) ;
3333
+ return Ok ( false ) ;
3321
3334
}
3322
3335
3336
+ let notify_type = if self . is_direct ( ) . await . unwrap_or ( false ) {
3337
+ NotifyType :: Ring
3338
+ } else {
3339
+ NotifyType :: Notify
3340
+ } ;
3341
+
3342
+ debug ! ( "Sending `m.call.notify` event with notify type: {notify_type:?}" ) ;
3343
+
3323
3344
self . send_call_notification (
3324
3345
self . room_id ( ) . to_string ( ) . to_owned ( ) ,
3325
3346
ApplicationType :: Call ,
3326
- if self . is_direct ( ) . await . unwrap_or ( false ) {
3327
- NotifyType :: Ring
3328
- } else {
3329
- NotifyType :: Notify
3330
- } ,
3347
+ notify_type,
3331
3348
Mentions :: with_room_mention ( ) ,
3332
3349
)
3333
3350
. await ?;
3334
3351
3335
- Ok ( ( ) )
3352
+ Ok ( true )
3336
3353
}
3337
3354
3338
3355
/// Get the beacon information event in the room for the `user_id`.
0 commit comments