fix: send presence too often

This commit is contained in:
timokoesters 2020-06-04 22:36:48 +02:00
parent 32da76b9a2
commit d404f902bf
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
4 changed files with 36 additions and 74 deletions

View file

@ -59,23 +59,11 @@ impl RoomEdus {
prefix.push(0xff);
let mut first_possible_edu = prefix.clone();
first_possible_edu.extend_from_slice(&since.to_be_bytes());
first_possible_edu.extend_from_slice(&(since + 1).to_be_bytes()); // +1 so we don't send the event at since
Ok(self
.roomlatestid_roomlatest
.range(&*first_possible_edu..)
// Skip the first pdu if it's exactly at since, because we sent that last time
.skip(
if self
.roomlatestid_roomlatest
.get(first_possible_edu)?
.is_some()
{
1
} else {
0
},
)
.filter_map(|r| r.ok())
.take_while(move |(k, _)| k.starts_with(&prefix))
.map(|(_, v)| Ok(serde_json::from_slice(&v)?)))