[fractal/574-empty-next-batch: 4/4] API: handle empty `next_batch` fields



commit 0ed0c835e62ea9e9f6a7e69661a8af93fed314f1
Author: Alexandre Franke <afranke gnome org>
Date:   Sat Jan 25 12:20:19 2020 +0100

    API: handle empty `next_batch` fields
    
    Fixes #574

 fractal-matrix-api/src/backend/sync.rs        | 2 +-
 fractal-matrix-api/src/r0/sync/sync_events.rs | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/sync.rs b/fractal-matrix-api/src/backend/sync.rs
index 4c520be7..c02c8b71 100644
--- a/fractal-matrix-api/src/backend/sync.rs
+++ b/fractal-matrix-api/src/backend/sync.rs
@@ -245,7 +245,7 @@ pub fn sync(
                         .expect_log("Connection closed");
                 }
 
-                let next_batch = response.next_batch;
+                let next_batch = response.next_batch.unwrap_or_default();
                 tx.send(BKResponse::Sync(Ok(next_batch)))
                     .expect_log("Connection closed");
             }
diff --git a/fractal-matrix-api/src/r0/sync/sync_events.rs b/fractal-matrix-api/src/r0/sync/sync_events.rs
index 95bae1ac..dbbbdbfd 100644
--- a/fractal-matrix-api/src/r0/sync/sync_events.rs
+++ b/fractal-matrix-api/src/r0/sync/sync_events.rs
@@ -68,7 +68,7 @@ impl MarkPresence {
 
 #[derive(Clone, Debug, Deserialize)]
 pub struct Response {
-    pub next_batch: String,
+    pub next_batch: Option<String>,
     #[serde(default)]
     pub rooms: Rooms,
     pub presence: Option<Presence>,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]