fix: set limited to true when skipping messages in /sync
This commit is contained in:
		
							parent
							
								
									e457e19088
								
							
						
					
					
						commit
						f23fb32e95
					
				
					 5 changed files with 24 additions and 10 deletions
				
			
		
							
								
								
									
										13
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										13
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							|  | @ -1560,6 +1560,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma" | name = "ruma" | ||||||
| version = "0.0.1" | version = "0.0.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "ruma-api", |  "ruma-api", | ||||||
|  "ruma-client-api", |  "ruma-client-api", | ||||||
|  | @ -1573,6 +1574,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-api" | name = "ruma-api" | ||||||
| version = "0.17.0-alpha.1" | version = "0.17.0-alpha.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "http", |  "http", | ||||||
|  "percent-encoding", |  "percent-encoding", | ||||||
|  | @ -1587,6 +1589,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-api-macros" | name = "ruma-api-macros" | ||||||
| version = "0.17.0-alpha.1" | version = "0.17.0-alpha.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "proc-macro-crate", |  "proc-macro-crate", | ||||||
|  "proc-macro2", |  "proc-macro2", | ||||||
|  | @ -1597,6 +1600,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-client-api" | name = "ruma-client-api" | ||||||
| version = "0.10.0-alpha.1" | version = "0.10.0-alpha.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "assign", |  "assign", | ||||||
|  "http", |  "http", | ||||||
|  | @ -1614,6 +1618,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-common" | name = "ruma-common" | ||||||
| version = "0.2.0" | version = "0.2.0" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "js_int", |  "js_int", | ||||||
|  "ruma-identifiers", |  "ruma-identifiers", | ||||||
|  | @ -1626,6 +1631,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-events" | name = "ruma-events" | ||||||
| version = "0.22.0-alpha.1" | version = "0.22.0-alpha.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "js_int", |  "js_int", | ||||||
|  "ruma-common", |  "ruma-common", | ||||||
|  | @ -1640,6 +1646,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-events-macros" | name = "ruma-events-macros" | ||||||
| version = "0.22.0-alpha.1" | version = "0.22.0-alpha.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "proc-macro-crate", |  "proc-macro-crate", | ||||||
|  "proc-macro2", |  "proc-macro2", | ||||||
|  | @ -1650,6 +1657,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-federation-api" | name = "ruma-federation-api" | ||||||
| version = "0.0.3" | version = "0.0.3" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "js_int", |  "js_int", | ||||||
|  "ruma-api", |  "ruma-api", | ||||||
|  | @ -1664,6 +1672,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-identifiers" | name = "ruma-identifiers" | ||||||
| version = "0.17.4" | version = "0.17.4" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "rand", |  "rand", | ||||||
|  "ruma-identifiers-macros", |  "ruma-identifiers-macros", | ||||||
|  | @ -1675,6 +1684,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-identifiers-macros" | name = "ruma-identifiers-macros" | ||||||
| version = "0.17.4" | version = "0.17.4" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "proc-macro2", |  "proc-macro2", | ||||||
|  "quote", |  "quote", | ||||||
|  | @ -1685,6 +1695,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-identifiers-validation" | name = "ruma-identifiers-validation" | ||||||
| version = "0.1.1" | version = "0.1.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "ruma-serde", |  "ruma-serde", | ||||||
|  "serde", |  "serde", | ||||||
|  | @ -1695,6 +1706,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-serde" | name = "ruma-serde" | ||||||
| version = "0.2.3" | version = "0.2.3" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "form_urlencoded", |  "form_urlencoded", | ||||||
|  "itoa", |  "itoa", | ||||||
|  | @ -1706,6 +1718,7 @@ dependencies = [ | ||||||
| [[package]] | [[package]] | ||||||
| name = "ruma-signatures" | name = "ruma-signatures" | ||||||
| version = "0.6.0-dev.1" | version = "0.6.0-dev.1" | ||||||
|  | source = "git+https://github.com/timokoesters/ruma?branch=timo-fixes#c2adc9ecb85538505ff351dbd883c9106f651744" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "base64 0.12.3", |  "base64 0.12.3", | ||||||
|  "ring", |  "ring", | ||||||
|  |  | ||||||
|  | @ -17,8 +17,8 @@ edition = "2018" | ||||||
| rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", features = ["tls"] } | 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/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 = { 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 = { path = "../ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] } | ||||||
| tokio = "0.2.22" # Used for long polling | tokio = "0.2.22" # Used for long polling | ||||||
| sled = "0.32.0" # Used for storing data permanently | sled = "0.32.0" # Used for storing data permanently | ||||||
| log = "0.4.8" # Used for emitting log entries | log = "0.4.8" # Used for emitting log entries | ||||||
|  |  | ||||||
|  | @ -60,10 +60,10 @@ pub fn search_events_route( | ||||||
|             Ok::<_, Error>(SearchResult { |             Ok::<_, Error>(SearchResult { | ||||||
|                 context: None, |                 context: None, | ||||||
|                 rank: None, |                 rank: None, | ||||||
|                 result: dbg!(db |                 result: db | ||||||
|                     .rooms |                     .rooms | ||||||
|                     .get_pdu_from_id(dbg!(&result))? |                     .get_pdu_from_id(&result)? | ||||||
|                     .map(|pdu| pdu.to_room_event())), |                     .map(|pdu| pdu.to_room_event()), | ||||||
|             }) |             }) | ||||||
|         }) |         }) | ||||||
|         .filter_map(|r| r.ok()) |         .filter_map(|r| r.ok()) | ||||||
|  |  | ||||||
|  | @ -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
 |         // They /sync response doesn't always return all messages, so we say the output is
 | ||||||
|         // limited unless there are events in non_timeline_pdus
 |         // limited unless there are events in non_timeline_pdus
 | ||||||
|         //let mut limited = false;
 |         let mut limited = false; | ||||||
| 
 | 
 | ||||||
|         let mut state_pdus = Vec::new(); |         let mut state_pdus = Vec::new(); | ||||||
|         for pdu in non_timeline_pdus { |         for pdu in non_timeline_pdus { | ||||||
|             if pdu.state_key.is_some() { |             if pdu.state_key.is_some() { | ||||||
|                 state_pdus.push(pdu); |                 state_pdus.push(pdu); | ||||||
|             } |             } | ||||||
|  |             limited = true; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         let mut send_member_count = false; |         let mut send_member_count = false; | ||||||
|  | @ -271,7 +272,7 @@ pub async fn sync_events_route( | ||||||
|                 notification_count, |                 notification_count, | ||||||
|             }, |             }, | ||||||
|             timeline: sync_events::Timeline { |             timeline: sync_events::Timeline { | ||||||
|                 limited: joined_since_last_sync, |                 limited: limited || joined_since_last_sync, | ||||||
|                 prev_batch, |                 prev_batch, | ||||||
|                 events: room_events, |                 events: room_events, | ||||||
|             }, |             }, | ||||||
|  |  | ||||||
|  | @ -575,7 +575,7 @@ impl Rooms { | ||||||
|             self.roomstateid_pdu.insert(key, &*pdu_json.to_string())?; |             self.roomstateid_pdu.insert(key, &*pdu_json.to_string())?; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         match dbg!(event_type) { |         match event_type { | ||||||
|             EventType::RoomRedaction => { |             EventType::RoomRedaction => { | ||||||
|                 if let Some(redact_id) = &redacts { |                 if let Some(redact_id) = &redacts { | ||||||
|                     // TODO: Reason
 |                     // TODO: Reason
 | ||||||
|  | @ -619,7 +619,7 @@ impl Rooms { | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             EventType::RoomMessage => { |             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 |                     for word in body | ||||||
|                         .split_terminator(|c: char| !c.is_alphanumeric()) |                         .split_terminator(|c: char| !c.is_alphanumeric()) | ||||||
|                         .map(str::to_lowercase) |                         .map(str::to_lowercase) | ||||||
|  | @ -1002,7 +1002,7 @@ impl Rooms { | ||||||
|                     .iter_mut() |                     .iter_mut() | ||||||
|                     .map(|it| { |                     .map(|it| { | ||||||
|                         while let Some(element) = it.peek() { |                         while let Some(element) = it.peek() { | ||||||
|                             if dbg!(element) > dbg!(target) { |                             if element > target { | ||||||
|                                 return false; |                                 return false; | ||||||
|                             } else if element == target { |                             } else if element == target { | ||||||
|                                 return true; |                                 return true; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue