Skip to content

Commit

Permalink
ffi: Allow disabling local notification filtering using push rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 authored Jun 26, 2023
1 parent 8916eb6 commit 2c58c65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,15 @@ impl Client {
&self,
room_id: String,
event_id: String,
filter_by_push_rules: bool,
) -> Result<Option<NotificationItem>, ClientError> {
RUNTIME.block_on(async move {
// We may also need to do a sync here since this may fail if the keys are not
// valid anymore
let room_id = RoomId::parse(room_id)?;
let room = self.inner.get_room(&room_id).context("Room not found")?;
let notification = NotificationItem::new_from_event_id(&event_id, room).await?;
let notification =
NotificationItem::new_from_event_id(&event_id, room, filter_by_push_rules).await?;
Ok(notification)
})
}
Expand Down
3 changes: 2 additions & 1 deletion bindings/matrix-sdk-ffi/src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ impl NotificationItem {
pub(crate) async fn new_from_event_id(
event_id: &str,
room: Room,
filter_by_push_rules: bool,
) -> anyhow::Result<Option<Self>> {
let event_id = EventId::parse(event_id)?;
let ruma_event = room.event(&event_id).await?;

if !ruma_event.push_actions.iter().any(|a| a.should_notify()) {
if filter_by_push_rules && !ruma_event.push_actions.iter().any(|a| a.should_notify()) {
return Ok(None);
}

Expand Down

0 comments on commit 2c58c65

Please sign in to comment.