fix: set limited to true when skipping messages in /sync

This commit is contained in:
Timo 2020-08-19 18:26:39 +02:00
parent e457e19088
commit f23fb32e95
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
5 changed files with 24 additions and 10 deletions

13
Cargo.lock generated
View file

@ -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",

View file

@ -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

View file

@ -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())

View file

@ -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,
},

View file

@ -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;