From cc4ae3db1ed1d3c4c692fb7b7c88e0bb92b59c58 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Thu, 16 Jul 2020 06:13:35 -0700 Subject: [PATCH] Client::SyncSettings: Include sync filter --- matrix_sdk/src/client.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index af962e7a..2101bea5 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -203,6 +203,7 @@ impl ClientConfig { #[derive(Debug, Default, Clone)] /// Settings for a sync call. pub struct SyncSettings { + pub(crate) filter: Option, pub(crate) timeout: Option, pub(crate) token: Option, pub(crate) full_state: bool, @@ -235,6 +236,17 @@ impl SyncSettings { self } + /// Set the sync filter. + /// It can be either the filter ID, or the definition for the filter. + /// + /// # Arguments + /// + /// * `filter` - The filter configuration that should be used for the sync call. + pub fn filter(mut self, filter: sync_events::Filter) -> Self { + self.filter = Some(filter); + self + } + /// Should the server return the full state from the start of the timeline. /// /// This does nothing if no sync token is set. @@ -1222,7 +1234,7 @@ impl Client { #[instrument] pub async fn sync(&self, sync_settings: SyncSettings) -> Result { let request = sync_events::Request { - filter: None, + filter: sync_settings.filter, since: sync_settings.token, full_state: sync_settings.full_state, set_presence: sync_events::SetPresence::Online,