matrix-org / matrix-rust-sdk

Matrix Client-Server SDK for Rust
Apache License 2.0
1.16k stars 227 forks source link

Notifications: allow resolving multiple notifications at once #3476

Open ganfra opened 2 months ago

ganfra commented 2 months ago

Context : https://github.com/element-hq/element-x-android/issues/2910

The idea would be to expose a new api to resolve multiple notifications. Indeed, currently we are running a lot of sliding sync requests where we could probably run only one with all the rooms subscribed.

The api could looks like that :

pub enum NotificationResult {
    Resolved(NotificationItem),
    FilteredOut,
    Failed(Error),
}
 pub async fn get_notifications(
        &self,
        params: Vec<(RoomId, EventId)>,
    ) -> Vec<NotificationResult>

We need to make sure the EventId and RoomId are available in the NotificationItem so we can map them back in the client.

bnjbvr commented 2 months ago

Sounds good to me, thanks! One small nitpick on the name is that "Result" should not be used for things that aren't Result<..., ...>; maybe Outcome would work nicely as a suffix.