Compare commits
2 changed files with 4 additions and 19 deletions
|
|
@ -890,7 +890,6 @@ pub async fn collect_unread_with_ids(
|
||||||
) -> Vec<(matrix_sdk::ruma::OwnedRoomId, crate::protocol::RoomUnread)> {
|
) -> Vec<(matrix_sdk::ruma::OwnedRoomId, crate::protocol::RoomUnread)> {
|
||||||
use crate::protocol::RoomUnread;
|
use crate::protocol::RoomUnread;
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
let own_user_id = client.user_id();
|
|
||||||
for room in client.joined_rooms() {
|
for room in client.joined_rooms() {
|
||||||
let count =
|
let count =
|
||||||
u32::try_from(room.unread_notification_counts().notification_count).unwrap_or(u32::MAX);
|
u32::try_from(room.unread_notification_counts().notification_count).unwrap_or(u32::MAX);
|
||||||
|
|
@ -903,16 +902,6 @@ pub async fn collect_unread_with_ids(
|
||||||
} else {
|
} else {
|
||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
// Skip a single-unread room whose newest event is the agent's own
|
|
||||||
// message: after a rebuild the read receipt may not have advanced
|
|
||||||
// past it yet, so `notification_count` can still report 1 — without
|
|
||||||
// this the agent self-wakes on its own message. Only reachable on the
|
|
||||||
// count==1 path, where `last_sender` is populated.
|
|
||||||
if let (Some(sender), Some(own_id)) = (&last_sender, own_user_id)
|
|
||||||
&& sender.as_str() == own_id.as_str()
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result.push((
|
result.push((
|
||||||
room.room_id().to_owned(),
|
room.room_id().to_owned(),
|
||||||
RoomUnread {
|
RoomUnread {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,8 @@
|
||||||
//!
|
//!
|
||||||
//! Todo summaries stay short: `sweep_unread` pushes the per-room unread
|
//! Todo summaries stay short: `sweep_unread` pushes the per-room unread
|
||||||
//! summary (`wake::format_unread_summary`); the message stays unread
|
//! summary (`wake::format_unread_summary`); the message stays unread
|
||||||
//! server-side so the agent fetches detail via `read_room`. A self-authored
|
//! server-side so the agent fetches detail via `read_room`. Self-sent
|
||||||
//! newest message can still read as unread after a rebuild (the read receipt
|
//! messages never raise an unread notification, so they never wake.
|
||||||
//! lags), so `collect_unread_with_ids` filters those rooms out — the agent
|
|
||||||
//! never wakes on its own message.
|
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
|
@ -35,10 +33,8 @@ use crate::{handlers, wake};
|
||||||
/// `Some(name)` only in multi-account mode, prepended so the agent knows
|
/// `Some(name)` only in multi-account mode, prepended so the agent knows
|
||||||
/// which account to `read_room` on.
|
/// which account to `read_room` on.
|
||||||
///
|
///
|
||||||
/// Rooms whose newest unread event is the agent's own message are filtered
|
/// Self-sent messages don't raise an unread notification server-side, so
|
||||||
/// out by `collect_unread_with_ids` (after a rebuild a stale read receipt can
|
/// no explicit self-filter is needed here.
|
||||||
/// otherwise leave a self-authored message counted as unread and self-wake
|
|
||||||
/// the agent).
|
|
||||||
pub async fn sweep_unread(
|
pub async fn sweep_unread(
|
||||||
client: &Client,
|
client: &Client,
|
||||||
notified: &Mutex<HashSet<OwnedRoomId>>,
|
notified: &Mutex<HashSet<OwnedRoomId>>,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue