Don't send empty presence EDUs
I run a homeserver whose logs show a high number of incoming empty presence EDUs originating from the user agent "Conduwuit/0.4.4". They arrive at a rate of about 2 queries per second per Conduwuit server. The empty EDUs all look the same, only with `origin_server_ts` increasing: ``` {"origin":"example.com","origin_server_ts":1720266475601,"edus":[{"edu_type":"m.presence","content":{"push":[]}}]} ``` These updates are unnecessary because they don't do anything. They only increase network traffic and CPU usage on both sides. After this commit, the empty presence updates are no longer inserted into the outgoing event queue.
This commit is contained in:
parent
8691141237
commit
2bc53139fa
1 changed files with 4 additions and 2 deletions
|
@ -324,8 +324,10 @@ fn select_edus_presence(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let presence_content = Edu::Presence(PresenceContent::new(presence_updates));
|
if !presence_updates.is_empty() {
|
||||||
events.push(serde_json::to_vec(&presence_content).expect("PresenceEvent can be serialized"));
|
let presence_content = Edu::Presence(PresenceContent::new(presence_updates));
|
||||||
|
events.push(serde_json::to_vec(&presence_content).expect("PresenceEvent can be serialized"));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue