From 8da228c63487082558628d9ea6425fa477d19663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Thu, 11 Sep 2025 14:02:13 +0200 Subject: [PATCH] feat: Add `disable_badge_count` field to set pusher request This allows the clients to stop receiving push notifications for unread counts in their devices, when it's not useful. --- Cargo.lock | 27 +++++++++------------------ Cargo.toml | 3 ++- bindings/matrix-sdk-ffi/Cargo.toml | 6 ++++-- bindings/matrix-sdk-ffi/src/client.rs | 4 ++++ crates/matrix-sdk/Cargo.toml | 3 +++ crates/matrix-sdk/src/pusher.rs | 2 ++ xtask/src/ci.rs | 2 +- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f53a99a0feb..f5002d31a54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4734,8 +4734,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7b698b728bc3747f564a9115c83b4f2e229b52377f6a1cca2e6add9cf4a13be" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "assign", "js_int", @@ -4752,8 +4751,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b54e56c591f9ad686defb0bacbebba5c8882eb0c9f8734f6a080345b4e3dd941" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "as_variant", "assign", @@ -4776,8 +4774,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac7f59b9f7639667d0d6ae3ae242c8912e9ed061cea1fbaf72710a402e83b53e" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "as_variant", "base64", @@ -4810,8 +4807,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34fa815769ed4fe1ef5b50aa0ba6f350317c13b5a9f1e008b014f4a3ddf14204" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "as_variant", "indexmap", @@ -4837,8 +4833,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecbc887ba1292e48e6363b29e0dec4571b52d2b5102ebf60068105efadaa6e0a" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "headers", "http", @@ -4858,8 +4853,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6124d74847ea788601477c89a44485894432a806824cae93885c5825a8ae9dbc" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "as_variant", "html5ever", @@ -4870,8 +4864,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14a7b93ac1e571c585f8fa5cef09c07bb8a15529775fd56b9a3eac4f9233dff2" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "js_int", "thiserror 2.0.16", @@ -4880,8 +4873,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9911c7188517f28505d2d513339511d00e0f50cec5c2dde820cd0ec7e6a833" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "cfg-if", "proc-macro-crate", @@ -4896,8 +4888,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47cd146d56ae6e7a4a8d912a30dfe57c70e5bf18806fdf617527d4d4f2dd2a4" +source = "git+https://github.com/jmartinesp/ruma?rev=0dac817a7a3b4c08993ab275c47033d8f797a3f3#0dac817a7a3b4c08993ab275c47033d8f797a3f3" dependencies = [ "base64", "ed25519-dalek", diff --git a/Cargo.toml b/Cargo.toml index 5b100ab47fd..5d1a3f3752e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,8 @@ rand = "0.8.5" regex = "1.11.2" reqwest = { version = "0.12.23", default-features = false } rmp-serde = "1.3.0" -ruma = { version = "0.13.0", features = [ +# TODO: revert this before merging +ruma = { git = "https://github.com/jmartinesp/ruma", rev = "0dac817a7a3b4c08993ab275c47033d8f797a3f3", features = [ "client-api-c", "compat-upload-signatures", "compat-arbitrary-length-ids", diff --git a/bindings/matrix-sdk-ffi/Cargo.toml b/bindings/matrix-sdk-ffi/Cargo.toml index f1fa9282b46..104a2082980 100644 --- a/bindings/matrix-sdk-ffi/Cargo.toml +++ b/bindings/matrix-sdk-ffi/Cargo.toml @@ -24,7 +24,7 @@ crate-type = [ ] [features] -default = ["bundled-sqlite", "unstable-msc4274"] +default = ["bundled-sqlite", "unstable-msc4274", "unstable-msc4076"] bundled-sqlite = ["matrix-sdk/bundled-sqlite"] unstable-msc4274 = ["matrix-sdk-ui/unstable-msc4274"] # Required when targeting a Javascript environment, like Wasm in a browser. @@ -36,6 +36,8 @@ rustls-tls = ["matrix-sdk/rustls-tls", "sentry?/rustls"] # Enable sentry error monitoring, not compatible with Wasm platforms. sentry = ["dep:sentry", "dep:sentry-tracing"] +unstable-msc4076 = ["matrix-sdk/unstable-msc4076"] + [dependencies] anyhow.workspace = true extension-trait = "1.0.1" @@ -57,7 +59,7 @@ matrix-sdk-ffi-macros.workspace = true matrix-sdk-ui = { workspace = true, features = ["uniffi"] } mime = "0.3.16" once_cell.workspace = true -ruma = { workspace = true, features = ["html", "unstable-msc3488", "compat-unset-avatar", "unstable-msc3245-v1-compat", "unstable-msc4278", "unstable-hydra"] } +ruma = { workspace = true, features = ["html", "unstable-msc3488", "compat-unset-avatar", "unstable-msc3245-v1-compat", "unstable-msc4278", "unstable-hydra", "unstable-msc4076"] } serde.workspace = true serde_json.workspace = true sentry = { workspace = true, optional = true, default-features = false, features = [ diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 9a8d36716df..0e4f3bbc26d 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -1144,6 +1144,7 @@ impl Client { } /// Registers a pusher with given parameters + #[allow(clippy::too_many_arguments)] pub async fn set_pusher( &self, identifiers: PusherIdentifiers, @@ -1152,6 +1153,7 @@ impl Client { device_display_name: String, profile_tag: Option, lang: String, + #[cfg(feature = "unstable-msc4076")] disable_badge_count: bool, ) -> Result<(), ClientError> { let ids = identifiers.into(); @@ -1162,6 +1164,8 @@ impl Client { device_display_name, profile_tag, lang, + #[cfg(feature = "unstable-msc4076")] + disable_badge_count, }; self.inner.pusher().set(pusher_init.into()).await?; Ok(()) diff --git a/crates/matrix-sdk/Cargo.toml b/crates/matrix-sdk/Cargo.toml index d59e3678fea..7b32589978d 100644 --- a/crates/matrix-sdk/Cargo.toml +++ b/crates/matrix-sdk/Cargo.toml @@ -71,6 +71,9 @@ docsrs = ["e2e-encryption", "sqlite", "indexeddb", "sso-login", "qrcode"] # Add support for inline media galleries via msgtypes unstable-msc4274 = ["ruma/unstable-msc4274", "matrix-sdk-base/unstable-msc4274"] +# Add support for disabling the pusher badge count +unstable-msc4076 = ["ruma/unstable-msc4076"] + experimental-search = ["matrix-sdk-search"] [dependencies] diff --git a/crates/matrix-sdk/src/pusher.rs b/crates/matrix-sdk/src/pusher.rs index 3086cabaebb..c095352ed12 100644 --- a/crates/matrix-sdk/src/pusher.rs +++ b/crates/matrix-sdk/src/pusher.rs @@ -85,6 +85,8 @@ mod tests { lang: "EN".to_owned(), device_display_name: "name".to_owned(), profile_tag: None, + #[cfg(feature = "unstable-msc4076")] + disable_badge_count: true, }; let response = client.pusher().set(pusher.into()).await; diff --git a/xtask/src/ci.rs b/xtask/src/ci.rs index 7d7bff3c4a9..e2e323e3f5f 100644 --- a/xtask/src/ci.rs +++ b/xtask/src/ci.rs @@ -233,7 +233,7 @@ fn check_clippy() -> Result<()> { "rustup run {NIGHTLY} cargo clippy --workspace --all-targets --exclude matrix-sdk-crypto --exclude xtask --no-default-features - --features native-tls,sso-login,testing + --features native-tls,sso-login,testing,unstable-msc4076 -- -D warnings" ) .run()?;