Use Result for last_notification_read as zero-default not appropriate.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -812,6 +812,7 @@ async fn load_joined_room(
|
|||||||
services
|
services
|
||||||
.pusher
|
.pusher
|
||||||
.last_notification_read(sender_user, room_id)
|
.last_notification_read(sender_user, room_id)
|
||||||
|
.ok()
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
@@ -872,8 +873,9 @@ async fn load_joined_room(
|
|||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
});
|
});
|
||||||
|
|
||||||
let send_notification_counts =
|
let send_notification_counts = last_notification_read
|
||||||
last_notification_read.is_none_or(|last_count| last_count.gt(&since));
|
.flatten()
|
||||||
|
.is_none_or(|last_count| last_count.gt(&since));
|
||||||
|
|
||||||
let notification_count: OptionFuture<_> = send_notification_counts
|
let notification_count: OptionFuture<_> = send_notification_counts
|
||||||
.then(|| {
|
.then(|| {
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ async fn matcher(
|
|||||||
services
|
services
|
||||||
.pusher
|
.pusher
|
||||||
.last_notification_read(sender_user, &room_id)
|
.last_notification_read(sender_user, &room_id)
|
||||||
|
.unwrap_or_default()
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
|||||||
@@ -50,14 +50,13 @@ pub async fn highlight_count(&self, user_id: &UserId, room_id: &RoomId) -> u64 {
|
|||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
#[tracing::instrument(level = "debug", skip(self), ret(level = "trace"))]
|
#[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<u64> {
|
||||||
let key = (room_id, user_id);
|
let key = (room_id, user_id);
|
||||||
self.db
|
self.db
|
||||||
.roomuserid_lastnotificationread
|
.roomuserid_lastnotificationread
|
||||||
.qry(&key)
|
.qry(&key)
|
||||||
.await
|
.await
|
||||||
.deserialized()
|
.deserialized()
|
||||||
.unwrap_or(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
|
|||||||
Reference in New Issue
Block a user