From f23fb32e957bc20599315552b30e0f8f6a9f8343 Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 19 Aug 2020 18:26:39 +0200 Subject: [PATCH] fix: set limited to true when skipping messages in /sync --- Cargo.lock | 13 +++++++++++++ Cargo.toml | 4 ++-- src/client_server/search.rs | 6 +++--- src/client_server/sync.rs | 5 +++-- src/database/rooms.rs | 6 +++--- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 267f409..0a7334c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1560,6 +1560,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.0.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "ruma-api", "ruma-client-api", @@ -1573,6 +1574,7 @@ dependencies = [ [[package]] name = "ruma-api" version = "0.17.0-alpha.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "http", "percent-encoding", @@ -1587,6 +1589,7 @@ dependencies = [ [[package]] name = "ruma-api-macros" version = "0.17.0-alpha.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1597,6 +1600,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.10.0-alpha.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "assign", "http", @@ -1614,6 +1618,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.2.0" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "js_int", "ruma-identifiers", @@ -1626,6 +1631,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.22.0-alpha.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "js_int", "ruma-common", @@ -1640,6 +1646,7 @@ dependencies = [ [[package]] name = "ruma-events-macros" version = "0.22.0-alpha.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1650,6 +1657,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.0.3" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "js_int", "ruma-api", @@ -1664,6 +1672,7 @@ dependencies = [ [[package]] name = "ruma-identifiers" version = "0.17.4" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "rand", "ruma-identifiers-macros", @@ -1675,6 +1684,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-macros" version = "0.17.4" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "proc-macro2", "quote", @@ -1685,6 +1695,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.1.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "ruma-serde", "serde", @@ -1695,6 +1706,7 @@ dependencies = [ [[package]] name = "ruma-serde" version = "0.2.3" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "form_urlencoded", "itoa", @@ -1706,6 +1718,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.6.0-dev.1" +source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" dependencies = [ "base64 0.12.3", "ring", diff --git a/Cargo.toml b/Cargo.toml index ceb7883..4945e3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,8 +17,8 @@ edition = "2018" rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", features = ["tls"] } #ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "987d48666cf166cf12100b5dbc61b5e3385c4014" } # Used for matrix spec type definitions and helpers -#ruma = { git = "https://github.com/timokoesters/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "timo-fixes" } # Used for matrix spec type definitions and helpers -ruma = { path = "../ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] } +ruma = { git = "https://github.com/timokoesters/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "timo-fixes" } # Used for matrix spec type definitions and helpers +#ruma = { path = "../ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] } tokio = "0.2.22" # Used for long polling sled = "0.32.0" # Used for storing data permanently log = "0.4.8" # Used for emitting log entries diff --git a/src/client_server/search.rs b/src/client_server/search.rs index 9e465dd..1107555 100644 --- a/src/client_server/search.rs +++ b/src/client_server/search.rs @@ -60,10 +60,10 @@ pub fn search_events_route( Ok::<_, Error>(SearchResult { context: None, rank: None, - result: dbg!(db + result: db .rooms - .get_pdu_from_id(dbg!(&result))? - .map(|pdu| pdu.to_room_event())), + .get_pdu_from_id(&result)? + .map(|pdu| pdu.to_room_event()), }) }) .filter_map(|r| r.ok()) diff --git a/src/client_server/sync.rs b/src/client_server/sync.rs index e744ef9..201e8bc 100644 --- a/src/client_server/sync.rs +++ b/src/client_server/sync.rs @@ -69,13 +69,14 @@ pub async fn sync_events_route( // They /sync response doesn't always return all messages, so we say the output is // limited unless there are events in non_timeline_pdus - //let mut limited = false; + let mut limited = false; let mut state_pdus = Vec::new(); for pdu in non_timeline_pdus { if pdu.state_key.is_some() { state_pdus.push(pdu); } + limited = true; } let mut send_member_count = false; @@ -271,7 +272,7 @@ pub async fn sync_events_route( notification_count, }, timeline: sync_events::Timeline { - limited: joined_since_last_sync, + limited: limited || joined_since_last_sync, prev_batch, events: room_events, }, diff --git a/src/database/rooms.rs b/src/database/rooms.rs index 3b3c2c6..294531e 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -575,7 +575,7 @@ impl Rooms { self.roomstateid_pdu.insert(key, &*pdu_json.to_string())?; } - match dbg!(event_type) { + match event_type { EventType::RoomRedaction => { if let Some(redact_id) = &redacts { // TODO: Reason @@ -619,7 +619,7 @@ impl Rooms { } } EventType::RoomMessage => { - if let Some(body) = dbg!(content).get("body").and_then(|b| b.as_str()) { + if let Some(body) = content.get("body").and_then(|b| b.as_str()) { for word in body .split_terminator(|c: char| !c.is_alphanumeric()) .map(str::to_lowercase) @@ -1002,7 +1002,7 @@ impl Rooms { .iter_mut() .map(|it| { while let Some(element) = it.peek() { - if dbg!(element) > dbg!(target) { + if element > target { return false; } else if element == target { return true;