feature marked as experimental and executed rustfmt
This commit is contained in:
committed by
Jason Volk
parent
b5a9884194
commit
6295ca135a
@@ -19,13 +19,14 @@ use ruma::{
|
||||
MilliSecondsSinceUnixEpoch, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName,
|
||||
UInt,
|
||||
api::{
|
||||
appservice::event::push_events::v1::EphemeralData, federation::transactions::{
|
||||
appservice::event::push_events::v1::EphemeralData,
|
||||
federation::transactions::{
|
||||
edu::{
|
||||
DeviceListUpdateContent, Edu, PresenceContent, PresenceUpdate, ReceiptContent,
|
||||
ReceiptData, ReceiptMap,
|
||||
},
|
||||
send_transaction_message,
|
||||
}
|
||||
},
|
||||
},
|
||||
device_id,
|
||||
events::{
|
||||
@@ -833,21 +834,40 @@ impl Service {
|
||||
continue;
|
||||
}
|
||||
|
||||
// optional suppression: heuristic combining presence age and recent sync activity.
|
||||
if self.services.server.config.suppress_push_when_active {
|
||||
if let Ok(presence) = self.services.presence.get_presence(&user_id).await {
|
||||
let is_online = presence.content.presence == ruma::presence::PresenceState::Online;
|
||||
// optional suppression: heuristic combining presence age and recent sync
|
||||
// activity.
|
||||
if self
|
||||
.services
|
||||
.server
|
||||
.config
|
||||
.suppress_push_when_active
|
||||
{
|
||||
if let Ok(presence) = self
|
||||
.services
|
||||
.presence
|
||||
.get_presence(&user_id)
|
||||
.await
|
||||
{
|
||||
let is_online =
|
||||
presence.content.presence == ruma::presence::PresenceState::Online;
|
||||
let presence_age_ms = presence
|
||||
.content
|
||||
.last_active_ago
|
||||
.map(u64::from)
|
||||
.unwrap_or(u64::MAX);
|
||||
let sync_gap_ms = self.services.presence.last_sync_gap_ms(&user_id).await;
|
||||
let sync_gap_ms = self
|
||||
.services
|
||||
.presence
|
||||
.last_sync_gap_ms(&user_id)
|
||||
.await;
|
||||
let considered_active = is_online
|
||||
&& presence_age_ms < 65_000
|
||||
&& sync_gap_ms.is_some_and(|gap| gap < 32_000);
|
||||
if considered_active {
|
||||
trace!(?user_id, presence_age_ms, sync_gap_ms, "suppressing push: active heuristic");
|
||||
trace!(
|
||||
?user_id,
|
||||
presence_age_ms, sync_gap_ms, "suppressing push: active heuristic"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user