fix(#2629): exclude agent's own messages from unread sweep
Gate the unread sweep on sender: skip rooms where the latest unread message was sent by the agent itself. This prevents self-authored messages from triggering an unread notification and causing a self-wake loop. Fixes: #2629
This commit is contained in:
parent
3188e50ab8
commit
71cc545cb2
1 changed files with 8 additions and 0 deletions
|
|
@ -890,6 +890,7 @@ pub async fn collect_unread_with_ids(
|
|||
) -> Vec<(matrix_sdk::ruma::OwnedRoomId, crate::protocol::RoomUnread)> {
|
||||
use crate::protocol::RoomUnread;
|
||||
let mut result = Vec::new();
|
||||
let own_user_id = client.user_id();
|
||||
for room in client.joined_rooms() {
|
||||
let count =
|
||||
u32::try_from(room.unread_notification_counts().notification_count).unwrap_or(u32::MAX);
|
||||
|
|
@ -902,6 +903,13 @@ pub async fn collect_unread_with_ids(
|
|||
} else {
|
||||
(None, None)
|
||||
};
|
||||
// Skip rooms where the newest unread event was sent by the agent itself.
|
||||
// Self-authored messages should not trigger an unread notification.
|
||||
if let (Some(ref sender), Some(own_id)) = (&last_sender, own_user_id) {
|
||||
if sender == own_id.as_str() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result.push((
|
||||
room.room_id().to_owned(),
|
||||
RoomUnread {
|
||||
|
|
|
|||
Loading…
Reference in a new issue