From 001d8dc2573988b13da5e481a422fa8a1df109c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Wed, 14 Apr 2021 12:55:14 +0200 Subject: [PATCH] fix: don't do expensive operation on local /send --- src/database/pusher.rs | 2 +- src/database/rooms.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/database/pusher.rs b/src/database/pusher.rs index c204386..40b829f 100644 --- a/src/database/pusher.rs +++ b/src/database/pusher.rs @@ -218,7 +218,7 @@ pub fn get_actions<'a>( let ctx = PushConditionRoomCtx { room_id: pdu.room_id.clone(), - member_count: (db.rooms.room_members(&pdu.room_id).count() as u32).into(), + member_count: 10_u32.into(), // TODO: get member count efficiently user_display_name: db .users .displayname(&user)? diff --git a/src/database/rooms.rs b/src/database/rooms.rs index 5053360..955ad83 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -674,6 +674,7 @@ impl Rooms { .iter() .filter_map(|r| r.ok()) .filter(|user_id| self.is_joined(&user_id, &pdu.room_id).unwrap_or(false)) + .filter(|user_id| !db.users.is_deactivated(user_id).unwrap_or(false)) { // Don't notify the user of their own events if user == pdu.sender { @@ -706,15 +707,13 @@ impl Rooms { userroom_id.extend_from_slice(pdu.room_id.as_bytes()); if notify { - self - .userroomid_notificationcount + self.userroomid_notificationcount .update_and_fetch(&userroom_id, utils::increment)? .expect("utils::increment will always put in a value"); } if highlight { - self - .userroomid_highlightcount + self.userroomid_highlightcount .update_and_fetch(&userroom_id, utils::increment)? .expect("utils::increment will always put in a value"); }