diff --git a/src/api/client/sync/v3.rs b/src/api/client/sync/v3.rs index f79c3ded..cb7e78b6 100644 --- a/src/api/client/sync/v3.rs +++ b/src/api/client/sync/v3.rs @@ -812,6 +812,7 @@ async fn load_joined_room( services .pusher .last_notification_read(sender_user, room_id) + .ok() }) .into(); @@ -872,8 +873,9 @@ async fn load_joined_room( .map(Into::into) }); - let send_notification_counts = - last_notification_read.is_none_or(|last_count| last_count.gt(&since)); + let send_notification_counts = last_notification_read + .flatten() + .is_none_or(|last_count| last_count.gt(&since)); let notification_count: OptionFuture<_> = send_notification_counts .then(|| { diff --git a/src/api/client/sync/v5/selector.rs b/src/api/client/sync/v5/selector.rs index 917d872b..3922e125 100644 --- a/src/api/client/sync/v5/selector.rs +++ b/src/api/client/sync/v5/selector.rs @@ -102,6 +102,7 @@ async fn matcher( services .pusher .last_notification_read(sender_user, &room_id) + .unwrap_or_default() }) .into(); diff --git a/src/service/pusher/notification.rs b/src/service/pusher/notification.rs index 5cbb7c93..be16bc07 100644 --- a/src/service/pusher/notification.rs +++ b/src/service/pusher/notification.rs @@ -50,14 +50,13 @@ pub async fn highlight_count(&self, user_id: &UserId, room_id: &RoomId) -> u64 { #[implement(super::Service)] #[tracing::instrument(level = "debug", skip(self), ret(level = "trace"))] -pub async fn last_notification_read(&self, user_id: &UserId, room_id: &RoomId) -> u64 { +pub async fn last_notification_read(&self, user_id: &UserId, room_id: &RoomId) -> Result { let key = (room_id, user_id); self.db .roomuserid_lastnotificationread .qry(&key) .await .deserialized() - .unwrap_or(0) } #[implement(super::Service)]