remove unnecessary active_local_joined_users_in_room state_cache accessor

the underlying bug has been fixed

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-06-08 17:32:04 -04:00
parent 7f5b59afbb
commit 0524e6ed52
3 changed files with 8 additions and 42 deletions

View file

@ -2,7 +2,7 @@ use std::collections::HashSet;
use itertools::Itertools;
use ruma::{
events::{room::member::MembershipState, AnyStrippedStateEvent, AnySyncStateEvent},
events::{AnyStrippedStateEvent, AnySyncStateEvent},
serde::Raw,
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
};
@ -50,17 +50,10 @@ pub trait Data: Send + Sync {
/// in the room, even if they're deactivated/guests
fn local_users_in_room<'a>(&'a self, room_id: &RoomId) -> Box<dyn Iterator<Item = OwnedUserId> + 'a>;
/// Returns an iterator of all our local users in a room who are active (not
/// deactivated, not guest)
/// Returns an iterator of all our local joined users in a room who are
/// active (not deactivated, not guest)
fn active_local_users_in_room<'a>(&'a self, room_id: &RoomId) -> Box<dyn Iterator<Item = OwnedUserId> + 'a>;
/// Returns an iterator of all our local users joined in a room who are
/// active (not deactivated, not guest) and have a joined membership state
/// in the room
fn active_local_joined_users_in_room<'a>(
&'a self, room_id: &'a RoomId,
) -> Box<dyn Iterator<Item = OwnedUserId> + 'a>;
fn room_joined_count(&self, room_id: &RoomId) -> Result<Option<u64>>;
fn room_invited_count(&self, room_id: &RoomId) -> Result<Option<u64>>;
@ -412,8 +405,8 @@ impl Data for KeyValueDatabase {
)
}
/// Returns an iterator of all our local users in a room who are active (not
/// deactivated, not guest)
/// Returns an iterator of all our local joined users in a room who are
/// active (not deactivated, not guest)
#[tracing::instrument(skip(self))]
fn active_local_users_in_room<'a>(&'a self, room_id: &RoomId) -> Box<dyn Iterator<Item = OwnedUserId> + 'a> {
Box::new(
@ -422,23 +415,6 @@ impl Data for KeyValueDatabase {
)
}
/// Returns an iterator of all our local users joined in a room who are
/// active (not deactivated, not guest) and have a joined membership state
/// in the room
#[tracing::instrument(skip(self))]
fn active_local_joined_users_in_room<'a>(
&'a self, room_id: &'a RoomId,
) -> Box<dyn Iterator<Item = OwnedUserId> + 'a> {
Box::new(self.active_local_users_in_room(room_id).filter(|user_id| {
services()
.rooms
.state_accessor
.get_member(room_id, user_id)
.unwrap_or(None)
.map_or(false, |membership| membership.membership == MembershipState::Join)
}))
}
/// Returns the number of users which are currently in a room
#[tracing::instrument(skip(self))]
fn room_joined_count(&self, room_id: &RoomId) -> Result<Option<u64>> {

View file

@ -281,22 +281,12 @@ impl Service {
}
#[tracing::instrument(skip(self))]
/// Returns an iterator of all our local users in a room who are active (not
/// deactivated, not guest)
/// Returns an iterator of all our local joined users in a room who are
/// active (not deactivated, not guest)
pub fn active_local_users_in_room<'a>(&'a self, room_id: &RoomId) -> impl Iterator<Item = OwnedUserId> + 'a {
self.db.active_local_users_in_room(room_id)
}
#[tracing::instrument(skip(self))]
/// Returns an iterator of all our local users joined in a room who are
/// active (not deactivated, not guest) and have a joined membership state
/// in the room
pub fn active_local_joined_users_in_room<'a>(
&'a self, room_id: &'a RoomId,
) -> impl Iterator<Item = OwnedUserId> + 'a {
self.db.active_local_joined_users_in_room(room_id)
}
#[tracing::instrument(skip(self))]
pub fn room_invited_count(&self, room_id: &RoomId) -> Result<Option<u64>> { self.db.room_invited_count(room_id) }

View file

@ -310,7 +310,7 @@ impl Service {
let mut push_target = services()
.rooms
.state_cache
.active_local_joined_users_in_room(&pdu.room_id)
.active_local_users_in_room(&pdu.room_id)
.collect_vec();
if pdu.kind == TimelineEventType::RoomMember {