Skip to content

Commit 669ebf2

Browse files
zecakehbnjbvr
authored andcommitted
refactor(base): Don't take room ID in Notification::push_notification_from_event_if
It is already in the `PushConditionRoomCtx`, so we don't need an extra argument for it. Signed-off-by: Kévin Commaille <[email protected]>
1 parent 992774b commit 669ebf2

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

crates/matrix-sdk-base/src/response_processors/notification.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use std::collections::BTreeMap;
1616

1717
use ruma::{
18-
OwnedRoomId, RoomId,
18+
OwnedRoomId,
1919
push::{Action, PushConditionRoomCtx, Ruleset},
2020
serde::Raw,
2121
};
@@ -43,14 +43,11 @@ impl<'a> Notification<'a> {
4343

4444
fn push_notification(
4545
&mut self,
46-
room_id: &RoomId,
46+
room_id: OwnedRoomId,
4747
actions: Vec<Action>,
4848
event: RawAnySyncOrStrippedTimelineEvent,
4949
) {
50-
self.notifications
51-
.entry(room_id.to_owned())
52-
.or_default()
53-
.push(sync::Notification { actions, event });
50+
self.notifications.entry(room_id).or_default().push(sync::Notification { actions, event });
5451
}
5552

5653
/// Push a new [`sync::Notification`] in [`Self::notifications`] from
@@ -61,7 +58,6 @@ impl<'a> Notification<'a> {
6158
/// This method returns the fetched [`Action`]s.
6259
pub async fn push_notification_from_event_if<E, P>(
6360
&mut self,
64-
room_id: &RoomId,
6561
push_condition_room_ctx: &PushConditionRoomCtx,
6662
event: &Raw<E>,
6763
predicate: P,
@@ -73,7 +69,11 @@ impl<'a> Notification<'a> {
7369
let actions = self.push_rules.get_actions(event, push_condition_room_ctx).await;
7470

7571
if actions.iter().any(predicate) {
76-
self.push_notification(room_id, actions.to_owned(), event.clone().into());
72+
self.push_notification(
73+
push_condition_room_ctx.room_id.clone(),
74+
actions.to_owned(),
75+
event.clone().into(),
76+
);
7777
}
7878

7979
actions

crates/matrix-sdk-base/src/response_processors/state_events.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,10 @@ pub mod stripped {
277277
if let Some(push_condition_room_ctx) =
278278
timeline::get_push_room_context(context, room, room_info).await?
279279
{
280-
let room_id = room.room_id();
281-
282280
// Check every event again for notification.
283281
for event in state_events.values().flat_map(|map| map.values()) {
284282
notification
285283
.push_notification_from_event_if(
286-
room_id,
287284
&push_condition_room_ctx,
288285
event,
289286
Action::should_notify,

crates/matrix-sdk-base/src/response_processors/timeline.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ pub async fn build<'notification, 'e2ee>(
131131
if let Some(push_condition_room_ctx) = &push_condition_room_ctx {
132132
let actions = notification
133133
.push_notification_from_event_if(
134-
room_id,
135134
push_condition_room_ctx,
136135
timeline_event.raw(),
137136
Action::should_notify,

0 commit comments

Comments
 (0)