[fractal/fix-filtering: 2/2] filter: apply to all sync requests
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fix-filtering: 2/2] filter: apply to all sync requests
- Date: Sat, 17 Apr 2021 10:40:12 +0000 (UTC)
commit 2bf5b1a5d5002733cda898f749a14219e40ba301
Author: Alexandre Franke <afranke gnome org>
Date: Wed Apr 14 19:05:19 2021 +0200
filter: apply to all sync requests
fractal-gtk/src/backend/sync.rs | 50 +++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 27 deletions(-)
---
diff --git a/fractal-gtk/src/backend/sync.rs b/fractal-gtk/src/backend/sync.rs
index 93bbd930..84d68d44 100644
--- a/fractal-gtk/src/backend/sync.rs
+++ b/fractal-gtk/src/backend/sync.rs
@@ -64,43 +64,39 @@ pub async fn sync(
since: Option<String>,
number_tries: u32,
) -> Result<SyncResponse, SyncError> {
- let initial = since.is_none();
let timeline_not_types = [String::from("m.call.*")];
let timeline_types = [String::from("m.room.message"), String::from("m.sticker")];
let state_types = [String::from("m.room.*")];
- let sync_settings = if !initial {
- SyncSettings::new().timeout(Duration::from_secs(30))
- } else {
- // Don't filter event fields, it breaks deserialization.
- // Clearly the Matrix API is very static-typing-unfriendly right now.
- let filter = assign!(FilterDefinition::empty(), {
- presence: assign!(EventFilter::empty(), {
+
+ // Don't filter event fields, it breaks deserialization.
+ // Clearly the Matrix API is very static-typing-unfriendly right now.
+ let filter = assign!(FilterDefinition::empty(), {
+ presence: assign!(EventFilter::empty(), {
+ types: Some(&[]),
+ }),
+ room: assign!(RoomFilter::empty(), {
+ timeline: assign!(RoomEventFilter::empty(), {
+ not_types: &timeline_not_types,
+ limit: Some(globals::PAGE_LIMIT.into()),
+ types: Some(&timeline_types),
+ }),
+ ephemeral: assign!(RoomEventFilter::empty(), {
types: Some(&[]),
}),
- room: assign!(RoomFilter::empty(), {
- timeline: assign!(RoomEventFilter::empty(), {
- not_types: &timeline_not_types,
- limit: Some(globals::PAGE_LIMIT.into()),
- types: Some(&timeline_types),
- }),
- ephemeral: assign!(RoomEventFilter::empty(), {
- types: Some(&[]),
- }),
- state: assign!(RoomEventFilter::empty(), {
- types: Some(&state_types),
- lazy_load_options: LazyLoadOptions::Enabled {
- include_redundant_members: false,
- },
- }),
+ state: assign!(RoomEventFilter::empty(), {
+ types: Some(&state_types),
+ lazy_load_options: LazyLoadOptions::Enabled {
+ include_redundant_members: false,
+ },
}),
- });
+ }),
+ });
- SyncSettings::new().filter(Filter::FilterDefinition(filter))
- };
+ let sync_settings = SyncSettings::new().filter(Filter::FilterDefinition(filter));
let sync_settings = match since.clone() {
Some(sync_token) => sync_settings.token(sync_token),
- None => sync_settings,
+ None => sync_settings.timeout(Duration::from_secs(30)),
};
match session_client.sync_once(sync_settings).await {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]