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

This commit is contained in:
Timo 2020-08-19 18:26:39 +02:00 committed by Devin Ragotzy
parent 672bf4f473
commit 972babbc79
4 changed files with 54 additions and 19 deletions

View file

@ -532,7 +532,7 @@ impl Rooms {
self.append_state_pdu(&pdu.room_id, &pdu_id, state_key, &pdu.kind)?;
}
match pdu.kind {
match &pdu.kind {
EventType::RoomRedaction => {
if let Some(redact_id) = &pdu.redacts {
// TODO: Reason
@ -553,7 +553,7 @@ impl Rooms {
}
}
EventType::RoomMember => {
if let Some(state_key) = &pdu.state_key {
if let Some(state_key) = pdu.state_key.as_ref() {
// if the state_key fails
let target_user_id = UserId::try_from(state_key.as_str())
.expect("This state_key was previously validated");
@ -576,6 +576,21 @@ impl Rooms {
)?;
}
}
EventType::RoomMessage => {
if let Some(body) = pdu.content.get("body").and_then(|b| b.as_str()) {
for word in body
.split_terminator(|c: char| !c.is_alphanumeric())
.map(str::to_lowercase)
{
let mut key = pdu.room_id.to_string().as_bytes().to_vec();
key.push(0xff);
key.extend_from_slice(word.as_bytes());
key.push(0xff);
key.extend_from_slice(&pdu_id);
self.tokenids.insert(key, &[])?;
}
}
}
_ => {}
}
self.edus.room_read_set(&pdu.room_id, &pdu.sender, index)?;