tiny optimisation in append_pdu push notif
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
ee3c58f78f
commit
336de49e6a
|
@ -11,8 +11,7 @@ use std::{
|
||||||
use conduit::{
|
use conduit::{
|
||||||
debug, debug_warn, err, error, implement, info,
|
debug, debug_warn, err, error, implement, info,
|
||||||
pdu::{EventHash, PduBuilder, PduCount, PduEvent},
|
pdu::{EventHash, PduBuilder, PduCount, PduEvent},
|
||||||
utils,
|
utils::{self, stream::TryIgnore, IterStream, MutexMap, MutexMapGuard, ReadyExt},
|
||||||
utils::{stream::TryIgnore, IterStream, MutexMap, MutexMapGuard, ReadyExt},
|
|
||||||
validated, warn, Err, Error, Result, Server,
|
validated, warn, Err, Error, Result, Server,
|
||||||
};
|
};
|
||||||
pub use conduit::{PduId, RawPduId};
|
pub use conduit::{PduId, RawPduId};
|
||||||
|
@ -386,17 +385,19 @@ impl Service {
|
||||||
|
|
||||||
let sync_pdu = pdu.to_sync_room_event();
|
let sync_pdu = pdu.to_sync_room_event();
|
||||||
|
|
||||||
let mut notifies = Vec::new();
|
|
||||||
let mut highlights = Vec::new();
|
|
||||||
|
|
||||||
let mut push_target: HashSet<_> = 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)
|
||||||
|
// Don't notify the sender of their own events
|
||||||
|
.ready_filter(|user| user != &pdu.sender)
|
||||||
.map(ToOwned::to_owned)
|
.map(ToOwned::to_owned)
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
let mut notifies = Vec::with_capacity(push_target.len().saturating_add(1));
|
||||||
|
let mut highlights = Vec::with_capacity(push_target.len().saturating_add(1));
|
||||||
|
|
||||||
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())?;
|
let target_user_id = UserId::parse(state_key.clone())?;
|
||||||
|
@ -408,11 +409,6 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
for user in &push_target {
|
for user in &push_target {
|
||||||
// Don't notify the user of their own events
|
|
||||||
if user == &pdu.sender {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let rules_for_user = self
|
let rules_for_user = self
|
||||||
.services
|
.services
|
||||||
.account_data
|
.account_data
|
||||||
|
@ -436,6 +432,11 @@ impl Service {
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Break early if both conditions are true
|
||||||
|
if notify && highlight {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if notify {
|
if notify {
|
||||||
|
|
Loading…
Reference in New Issue