fix: dont add remote users for push targets, use hashset instead of vec
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
4eb7ad79d1
commit
98363852b1
1 changed files with 8 additions and 6 deletions
|
@ -43,7 +43,7 @@ use self::data::Data;
|
||||||
pub use self::data::PdusIterItem;
|
pub use self::data::PdusIterItem;
|
||||||
use crate::{
|
use crate::{
|
||||||
account_data, admin, appservice, appservice::NamespaceRegex, globals, pusher, rooms,
|
account_data, admin, appservice, appservice::NamespaceRegex, globals, pusher, rooms,
|
||||||
rooms::state_compressor::CompressedStateEvent, sending, server_keys, Dep,
|
rooms::state_compressor::CompressedStateEvent, sending, server_keys, users, Dep,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update Relationships
|
// Update Relationships
|
||||||
|
@ -90,6 +90,7 @@ struct Services {
|
||||||
sending: Dep<sending::Service>,
|
sending: Dep<sending::Service>,
|
||||||
server_keys: Dep<server_keys::Service>,
|
server_keys: Dep<server_keys::Service>,
|
||||||
user: Dep<rooms::user::Service>,
|
user: Dep<rooms::user::Service>,
|
||||||
|
users: Dep<users::Service>,
|
||||||
pusher: Dep<pusher::Service>,
|
pusher: Dep<pusher::Service>,
|
||||||
threads: Dep<rooms::threads::Service>,
|
threads: Dep<rooms::threads::Service>,
|
||||||
search: Dep<rooms::search::Service>,
|
search: Dep<rooms::search::Service>,
|
||||||
|
@ -119,6 +120,7 @@ impl crate::Service for Service {
|
||||||
sending: args.depend::<sending::Service>("sending"),
|
sending: args.depend::<sending::Service>("sending"),
|
||||||
server_keys: args.depend::<server_keys::Service>("server_keys"),
|
server_keys: args.depend::<server_keys::Service>("server_keys"),
|
||||||
user: args.depend::<rooms::user::Service>("rooms::user"),
|
user: args.depend::<rooms::user::Service>("rooms::user"),
|
||||||
|
users: args.depend::<users::Service>("users"),
|
||||||
pusher: args.depend::<pusher::Service>("pusher"),
|
pusher: args.depend::<pusher::Service>("pusher"),
|
||||||
threads: args.depend::<rooms::threads::Service>("rooms::threads"),
|
threads: args.depend::<rooms::threads::Service>("rooms::threads"),
|
||||||
search: args.depend::<rooms::search::Service>("rooms::search"),
|
search: args.depend::<rooms::search::Service>("rooms::search"),
|
||||||
|
@ -378,20 +380,20 @@ impl Service {
|
||||||
let mut notifies = Vec::new();
|
let mut notifies = Vec::new();
|
||||||
let mut highlights = Vec::new();
|
let mut highlights = Vec::new();
|
||||||
|
|
||||||
let mut push_target = self
|
let mut push_target: HashSet<_> = self
|
||||||
.services
|
.services
|
||||||
.state_cache
|
.state_cache
|
||||||
.active_local_users_in_room(&pdu.room_id)
|
.active_local_users_in_room(&pdu.room_id)
|
||||||
.map(ToOwned::to_owned)
|
.map(ToOwned::to_owned)
|
||||||
.collect::<Vec<_>>()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if pdu.kind == TimelineEventType::RoomMember {
|
if pdu.kind == TimelineEventType::RoomMember {
|
||||||
if let Some(state_key) = &pdu.state_key {
|
if let Some(state_key) = &pdu.state_key {
|
||||||
let target_user_id = UserId::parse(state_key.clone()).expect("This state_key was previously validated");
|
let target_user_id = UserId::parse(state_key.clone())?;
|
||||||
|
|
||||||
if !push_target.contains(&target_user_id) {
|
if self.services.users.is_active_local(&target_user_id).await {
|
||||||
push_target.push(target_user_id);
|
push_target.insert(target_user_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue