Skip to content

Commit 474c5d8

Browse files
committed
feat(push): add experimental support for MSC3768 (in-app-only notifications)
Signed-off-by: Johannes Marbach <[email protected]>
1 parent ada68e1 commit 474c5d8

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ proptest = { version = "1.6.0", default-features = false, features = ["std"] }
5959
rand = "0.8.5"
6060
reqwest = { version = "0.12.12", default-features = false }
6161
rmp-serde = "1.3.0"
62-
ruma = { git = "https://github.com/ruma/ruma", rev = "de19ebaf71af620eb17abaefd92e43153f9d041d", features = [
62+
ruma = { git = "https://github.com/ruma/ruma", rev = "dd7b085424930c34323a60ef360194c27a61459c", features = [
6363
"client-api-c",
6464
"compat-upload-signatures",
6565
"compat-arbitrary-length-ids",
@@ -70,14 +70,15 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "de19ebaf71af620eb17abaefd9
7070
"unstable-msc3401",
7171
"unstable-msc3488",
7272
"unstable-msc3489",
73+
"unstable-msc3768",
7374
"unstable-msc4075",
7475
"unstable-msc4140",
7576
"unstable-msc4143",
7677
"unstable-msc4171",
7778
"unstable-msc4278",
7879
"unstable-msc4286",
7980
] }
80-
ruma-common = { git = "https://github.com/ruma/ruma", rev = "de19ebaf71af620eb17abaefd92e43153f9d041d" }
81+
ruma-common = { git = "https://github.com/ruma/ruma", rev = "dd7b085424930c34323a60ef360194c27a61459c" }
8182
sentry = "0.36.0"
8283
sentry-tracing = "0.36.0"
8384
serde = { version = "1.0.217", features = ["rc"] }

bindings/matrix-sdk-ffi/src/notification_settings.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,12 @@ impl TryFrom<Tweak> for SdkTweak {
322322
#[derive(Clone, uniffi::Enum)]
323323
/// Enum representing the push notification actions for a rule.
324324
pub enum Action {
325-
/// Causes matching events to generate a notification.
325+
/// Causes matching events to generate a notification (both in-app and
326+
/// remote / push).
326327
Notify,
328+
/// Causes matching events to generate an in-app notification but no remote
329+
/// / push notification.
330+
NotifyInApp,
327331
/// Sets an entry in the 'tweaks' dictionary sent to the push gateway.
328332
SetTweak { value: Tweak },
329333
}
@@ -334,6 +338,7 @@ impl TryFrom<SdkAction> for Action {
334338
fn try_from(value: SdkAction) -> Result<Self, Self::Error> {
335339
Ok(match value {
336340
SdkAction::Notify => Self::Notify,
341+
SdkAction::NotifyInApp => Self::NotifyInApp,
337342
SdkAction::SetTweak(tweak) => Self::SetTweak {
338343
value: tweak.try_into().map_err(|e| format!("Failed to convert tweak: {e}"))?,
339344
},
@@ -348,6 +353,7 @@ impl TryFrom<Action> for SdkAction {
348353
fn try_from(value: Action) -> Result<Self, Self::Error> {
349354
Ok(match value {
350355
Action::Notify => Self::Notify,
356+
Action::NotifyInApp => Self::NotifyInApp,
351357
Action::SetTweak { value } => Self::SetTweak(
352358
value.try_into().map_err(|e| format!("Failed to convert tweak: {e}"))?,
353359
),

crates/matrix-sdk-ui/src/notification_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ impl NotificationClient {
677677

678678
let should_notify = push_actions
679679
.as_ref()
680-
.is_some_and(|actions| actions.iter().any(|a| a.should_notify()));
680+
.is_some_and(|actions| actions.iter().any(|a| a.should_notify_remote()));
681681

682682
if !should_notify {
683683
// The event has been filtered out by the user's push rules.
@@ -749,7 +749,7 @@ impl NotificationClient {
749749
}
750750

751751
if let Some(actions) = timeline_event.push_actions()
752-
&& !actions.iter().any(|a| a.should_notify())
752+
&& !actions.iter().any(|a| a.should_notify_remote())
753753
{
754754
return Ok(NotificationStatus::EventFilteredOut);
755755
}

0 commit comments

Comments
 (0)