Client::SyncSettings: Include sync filter

This commit is contained in:
Black Hat 2020-07-16 06:13:35 -07:00
parent a5c5f5a7b1
commit cc4ae3db1e

View file

@ -203,6 +203,7 @@ impl ClientConfig {
#[derive(Debug, Default, Clone)]
/// Settings for a sync call.
pub struct SyncSettings {
pub(crate) filter: Option<sync_events::Filter>,
pub(crate) timeout: Option<Duration>,
pub(crate) token: Option<String>,
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<sync_events::Response> {
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,