lazy-construct presence; avoids useless db queries in sender and syncer.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -571,7 +571,7 @@ async fn process_presence_updates(
|
||||
presence_updates: &mut HashMap<OwnedUserId, PresenceEvent>, since: u64, syncing_user: &OwnedUserId,
|
||||
) -> Result<()> {
|
||||
// Take presence updates
|
||||
for (user_id, _, presence_event) in services().presence.presence_since(since) {
|
||||
for (user_id, _, presence_bytes) in services().presence.presence_since(since) {
|
||||
if !services()
|
||||
.rooms
|
||||
.state_cache
|
||||
@@ -580,6 +580,8 @@ async fn process_presence_updates(
|
||||
continue;
|
||||
}
|
||||
|
||||
use crate::service::presence::Presence;
|
||||
let presence_event = Presence::from_json_bytes_to_event(&presence_bytes, &user_id)?;
|
||||
match presence_updates.entry(user_id) {
|
||||
Entry::Vacant(slot) => {
|
||||
slot.insert(presence_event);
|
||||
|
||||
Reference in New Issue
Block a user