matrix-org / matrix-org/matrix-rust-sdk

Expose 'append' parameter in Pusher::set() for multi-profile push notification support

Open
#6,102 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

## Summary

The `append` parameter for the `/_matrix/client/v3/pushers/set` endpoint is not exposed through the SDK's `Pusher::set()` method or the FFI bindings. This parameter is necessary for multi-profile/multi-account support where multiple Matrix accounts on the same device need to share a single APNS/FCM push token.

## Use Case

In our iOS app, we support multiple Matrix accounts logged in simultaneously. Each account needs to register for push notifications using the same device push token. Without the `append: true` flag, registering a pusher for one account removes the pusher for other accounts that share the same `pushkey` and `app_id`.

## Current Workaround

We currently bypass the SDK and make direct HTTP calls to the Matrix API:

```swift
// We have to make direct HTTP calls because the SDK doesn't expose the append flag
let pushersSetURL = homeserverURL.appendingPathComponent("_matrix/client/v3/pushers/set")
var request = URLRequest(url: pushersSetURL)
request.httpMethod = "POST"
// ... manually construct JSON body with "append": true
```

## Technical Details

The `append` flag already exists in Ruma's `PusherPostData`:

```rust
pub struct PusherPostData {
pub pusher: Pusher,
pub append: bool, // Already available!
}
```

However, the SDK's convenience method `Request::post(pusher)` hardcodes `append: false`, and neither the core SDK nor the FFI bindings expose this parameter.

## Proposed Solution

Add the `append` parameter with a default value of `false` to preserve backward compatibility:

1. **crates/matrix-sdk/src/pusher.rs** - Add `append` parameter with default:
```rust
pub async fn set(&self, pusher: Pusher, append: bool) -> Result<()> {
let action = PusherAction::Post(PusherPostData { pusher, append });
self.client.send(set_pusher::v3::Request::new(action)).await?;
Ok(())
}
```

2. **bindings/matrix-sdk-ffi/src/client.rs** - Add `append` to FFI with default `false`:
```rust
pub async fn set_pusher(
&self,
identifiers: PusherIdentifiers,
kind: PusherKind,
app_display_name: String,
device_display_name: String,
profile_tag: Option,
lang: String,
append: bool, // Default to false for backward compatibility
) -> Result<(), ClientError>
```

By defaulting `append` to `false`, this change preserves the existing behavior for all current consumers while enabling multi-account support for those who need it.

## References

- Matrix spec for pushers: https://spec.matrix.org/v1.6/client-server-api/#post_matrixclientv3pushersset
- The `append` field: "If true, the homeserver should add another pusher with the given pushkey and app id in addition to any others with different user ids."

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in crates/matrix-sdk/src/pusher.rs and inspect how Pusher::set builds PusherPostData and calls the pusher endpoint. Then review bindings/matrix-sdk-ffi/src/client.rs and the existing FFI set_pusher entry point. Done means append can be supplied through both APIs while retaining false behavior for existing callers.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.