add: mark all notifications as read/unread
fix: anonymous avatar/username
This commit is contained in:
parent
37e68079d8
commit
3f6f1eda9f
7 changed files with 118 additions and 10 deletions
|
@ -246,4 +246,26 @@ impl DataManager {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update_all_notifications_read(&self, user: &User, read: bool) -> Result<()> {
|
||||
let notifications = self.get_notifications_by_owner(user.id).await?;
|
||||
|
||||
if notifications.len() > 1000 {
|
||||
return Err(Error::MiscError(
|
||||
"Too many notifications to do this".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
for notification in notifications {
|
||||
if notification.read == read {
|
||||
// no need to update this
|
||||
continue;
|
||||
}
|
||||
|
||||
self.update_notification_read(notification.id, read, user)
|
||||
.await?
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue