add: open graph tags for posts and notes
This commit is contained in:
parent
af6fbdf04e
commit
0c509b7001
4 changed files with 97 additions and 20 deletions
|
@ -194,34 +194,38 @@ impl DataManager {
|
|||
}
|
||||
|
||||
pub async fn delete_all_notifications(&self, user: &User) -> Result<()> {
|
||||
let notifications = self.get_notifications_by_owner(user.id).await?;
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
||||
for notification in notifications {
|
||||
if user.id != notification.owner
|
||||
&& !user.permissions.check(FinePermission::MANAGE_NOTIFICATIONS)
|
||||
{
|
||||
return Err(Error::NotAllowed);
|
||||
}
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"DELETE FROM notifications WHERE owner = $1",
|
||||
&[&(user.id as i64)]
|
||||
);
|
||||
|
||||
self.delete_notification(notification.id, user).await?
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
self.update_user_notification_count(user.id, 0).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_all_notifications_by_tag(&self, user: &User, tag: &str) -> Result<()> {
|
||||
let notifications = self.get_notifications_by_tag(tag).await?;
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
||||
for notification in notifications {
|
||||
if user.id != notification.owner
|
||||
&& !user.permissions.check(FinePermission::MANAGE_NOTIFICATIONS)
|
||||
{
|
||||
return Err(Error::NotAllowed);
|
||||
}
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"DELETE FROM notifications WHERE owner = $1 AND tag = $2",
|
||||
params![&(user.id as i64), tag]
|
||||
);
|
||||
|
||||
self.delete_notification(notification.id, user).await?
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue