From 9269f009dbfcd167efb237df4d7dc3d9c8fd090e Mon Sep 17 00:00:00 2001 From: Guillem Nieto Date: Sat, 6 Jun 2020 17:23:14 +0200 Subject: [PATCH] Allow client to load history on newly joined rooms On /sync, check if a room is a new join between `since` parameter and now. If it's a newly joined room, set the limited flag to true, which will force the client to load room messages via the `/messages` endpoint. On `master`, I could not reproduce the messages not showing to others when joining after being invited. Fixes #39 --- src/client_server.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client_server.rs b/src/client_server.rs index d7fe641e..84e3cc8e 100644 --- a/src/client_server.rs +++ b/src/client_server.rs @@ -2149,13 +2149,13 @@ pub fn sync_route( .collect::>(); let mut send_member_count = false; - let mut send_full_state = false; + let mut joined_since_last_sync = false; let mut send_notification_counts = false; for pdu in &pdus { send_notification_counts = true; if pdu.kind == EventType::RoomMember { send_member_count = true; - if !send_full_state && pdu.state_key == Some(user_id.to_string()) { + if !joined_since_last_sync && pdu.state_key == Some(user_id.to_string()) { let content = serde_json::from_value::< EventJson, >(pdu.content.clone()) @@ -2163,8 +2163,8 @@ pub fn sync_route( .deserialize() .unwrap(); if content.membership == ruma::events::room::member::MembershipState::Join { - send_full_state = true; - // Both send_member_count and send_full_state are set. There's nothing more + joined_since_last_sync = true; + // Both send_member_count and joined_since_last_sync are set. There's nothing more // to do break; } @@ -2338,13 +2338,13 @@ pub fn sync_route( notification_count, }, timeline: sync_events::Timeline { - limited: if limited { Some(limited) } else { None }, + limited: if limited || joined_since_last_sync { Some(true) } else { None }, prev_batch, events: room_events, }, // TODO: state before timeline state: sync_events::State { - events: if send_full_state { + events: if joined_since_last_sync { state .into_iter() .map(|(_, pdu)| pdu.to_state_event())