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:
parent
7f5b59afbb
commit
0524e6ed52
3 changed files with 8 additions and 42 deletions
|
@ -2,7 +2,7 @@ use std::collections::HashSet;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
events::{room::member::MembershipState, AnyStrippedStateEvent, AnySyncStateEvent},
|
events::{AnyStrippedStateEvent, AnySyncStateEvent},
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
||||||
};
|
};
|
||||||
|
@ -50,17 +50,10 @@ pub trait Data: Send + Sync {
|
||||||
/// in the room, even if they're deactivated/guests
|
/// 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>;
|
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
|
/// Returns an iterator of all our local joined users in a room who are
|
||||||
/// deactivated, not guest)
|
/// active (not deactivated, not guest)
|
||||||
fn active_local_users_in_room<'a>(&'a self, room_id: &RoomId) -> Box<dyn Iterator<Item = OwnedUserId> + 'a>;
|
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_joined_count(&self, room_id: &RoomId) -> Result<Option<u64>>;
|
||||||
|
|
||||||
fn room_invited_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
|
/// Returns an iterator of all our local joined users in a room who are
|
||||||
/// deactivated, not guest)
|
/// active (not deactivated, not guest)
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
fn active_local_users_in_room<'a>(&'a self, room_id: &RoomId) -> Box<dyn Iterator<Item = OwnedUserId> + 'a> {
|
fn active_local_users_in_room<'a>(&'a self, room_id: &RoomId) -> Box<dyn Iterator<Item = OwnedUserId> + 'a> {
|
||||||
Box::new(
|
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
|
/// Returns the number of users which are currently in a room
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
fn room_joined_count(&self, room_id: &RoomId) -> Result<Option<u64>> {
|
fn room_joined_count(&self, room_id: &RoomId) -> Result<Option<u64>> {
|
||||||
|
|
|
@ -281,22 +281,12 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
/// Returns an iterator of all our local users in a room who are active (not
|
/// Returns an iterator of all our local joined users in a room who are
|
||||||
/// deactivated, not guest)
|
/// active (not deactivated, not guest)
|
||||||
pub fn active_local_users_in_room<'a>(&'a self, room_id: &RoomId) -> impl Iterator<Item = OwnedUserId> + 'a {
|
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)
|
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))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn room_invited_count(&self, room_id: &RoomId) -> Result<Option<u64>> { self.db.room_invited_count(room_id) }
|
pub fn room_invited_count(&self, room_id: &RoomId) -> Result<Option<u64>> { self.db.room_invited_count(room_id) }
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ impl Service {
|
||||||
let mut push_target = services()
|
let mut push_target = services()
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.active_local_joined_users_in_room(&pdu.room_id)
|
.active_local_users_in_room(&pdu.room_id)
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
if pdu.kind == TimelineEventType::RoomMember {
|
if pdu.kind == TimelineEventType::RoomMember {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue