Skip to content

Commit 066e8d6

Browse files
committed
refactor: Adapt to non-exhaustive PushConditionRoomCtx
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
1 parent 5b54749 commit 066e8d6

File tree

3 files changed

+34
-26
lines changed
  • crates

3 files changed

+34
-26
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use matrix_sdk_common::deserialized_responses::TimelineEvent;
1616
#[cfg(feature = "e2e-encryption")]
1717
use ruma::events::SyncMessageLikeEvent;
1818
use ruma::{
19+
assign,
1920
events::{
2021
room::power_levels::{
2122
RoomPowerLevelsEvent, RoomPowerLevelsEventContent, StrippedRoomPowerLevelsEvent,
@@ -294,11 +295,13 @@ pub async fn get_push_room_context(
294295
.map(|event| event.power_levels().into())
295296
};
296297

297-
Ok(Some(PushConditionRoomCtx {
298-
user_id: user_id.to_owned(),
299-
room_id: room_id.to_owned(),
300-
member_count: UInt::new(member_count).unwrap_or(UInt::MAX),
301-
user_display_name,
302-
power_levels,
303-
}))
298+
Ok(Some(assign!(
299+
PushConditionRoomCtx::new(
300+
room_id.to_owned(),
301+
UInt::new(member_count).unwrap_or(UInt::MAX),
302+
user_id.to_owned(),
303+
user_display_name
304+
),
305+
{ power_levels }
306+
)))
304307
}

crates/matrix-sdk-ui/src/timeline/tests/mod.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use matrix_sdk_base::{
4040
};
4141
use matrix_sdk_test::{event_factory::EventFactory, ALICE, DEFAULT_TEST_ROOM_ID};
4242
use ruma::{
43+
assign,
4344
events::{
4445
reaction::ReactionEventContent,
4546
receipt::{Receipt, ReceiptThread, ReceiptType},
@@ -406,18 +407,20 @@ impl RoomDataProvider for TestRoomDataProvider {
406407

407408
async fn push_context(&self) -> Option<PushContext> {
408409
let push_rules = Ruleset::server_default(&ALICE);
409-
let power_levels = PushConditionPowerLevelsCtx {
410-
users: BTreeMap::new(),
411-
users_default: int!(0),
412-
notifications: NotificationPowerLevels::new(),
413-
};
414-
let push_condition_room_ctx = PushConditionRoomCtx {
415-
room_id: room_id!("!my_room:server.name").to_owned(),
416-
member_count: uint!(2),
417-
user_id: ALICE.to_owned(),
418-
user_display_name: "Alice".to_owned(),
419-
power_levels: Some(power_levels),
420-
};
410+
let power_levels = PushConditionPowerLevelsCtx::new(
411+
BTreeMap::new(),
412+
int!(0),
413+
NotificationPowerLevels::new(),
414+
);
415+
let push_condition_room_ctx = assign!(
416+
PushConditionRoomCtx::new(
417+
room_id!("!my_room:server.name").to_owned(),
418+
uint!(2),
419+
ALICE.to_owned(),
420+
"Alice".to_owned(),
421+
),
422+
{ power_levels: Some(power_levels) }
423+
);
421424
Some(PushContext::new(push_condition_room_ctx, push_rules))
422425
}
423426

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,13 +2936,15 @@ impl Room {
29362936
.and_then(|e| e.deserialize().ok())
29372937
.map(|e| e.power_levels().into());
29382938

2939-
Ok(Some(PushConditionRoomCtx {
2940-
user_id: user_id.to_owned(),
2941-
room_id: room_id.to_owned(),
2942-
member_count: UInt::new(member_count).unwrap_or(UInt::MAX),
2943-
user_display_name,
2944-
power_levels,
2945-
}))
2939+
Ok(Some(assign!(
2940+
PushConditionRoomCtx::new(
2941+
room_id.to_owned(),
2942+
UInt::new(member_count).unwrap_or(UInt::MAX),
2943+
user_id.to_owned(),
2944+
user_display_name,
2945+
),
2946+
{ power_levels }
2947+
)))
29462948
}
29472949

29482950
/// Retrieves a [`PushContext`] that can be used to compute the push

0 commit comments

Comments
 (0)