From 5fef975ef2e1a75820cd5f7a871e43ff91fb6ff5 Mon Sep 17 00:00:00 2001 From: JCWasmx86 Date: Sat, 7 May 2022 08:05:29 +0200 Subject: [PATCH] fix(sdk): Don't send notifications for your own user --- crates/matrix-sdk-base/src/client.rs | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index 9008bd7fb..5afd1f8a5 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -373,19 +373,25 @@ impl BaseClient { } if let Some(context) = &push_context { - let actions = push_rules.get_actions(&event.event, context).to_vec(); + if event + .event + .get_field::("sender")? + .map_or(false, |id| id == user_id) + { + let actions = push_rules.get_actions(&event.event, context).to_vec(); - if actions.iter().any(|a| matches!(a, Action::Notify)) { - changes.add_notification( - room_id, - Notification::new( - actions, - event.event.clone(), - false, - room_id.to_owned(), - MilliSecondsSinceUnixEpoch::now(), - ), - ); + if actions.iter().any(|a| matches!(a, Action::Notify)) { + changes.add_notification( + room_id, + Notification::new( + actions, + event.event.clone(), + false, + room_id.to_owned(), + MilliSecondsSinceUnixEpoch::now(), + ), + ); + } } // TODO if there is an // Action::SetTweak(Tweak::Highlight) we need to store