add: mark all notifications as read/unread

fix: anonymous avatar/username
This commit is contained in:
trisua 2025-05-22 22:54:06 -04:00
parent 37e68079d8
commit 3f6f1eda9f
7 changed files with 118 additions and 10 deletions

View file

@ -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(())
}
}