Prevent duplication of mention on post update

and delete mentions and notifications of user no longer mentioned
This commit is contained in:
Trinity Pointard
2018-10-27 21:48:38 +02:00
committed by Baptiste Gelez
parent 1689813df4
commit 2523f3b523
3 changed files with 19 additions and 2 deletions
+6
View File
@@ -102,6 +102,12 @@ impl Mention {
})
}
}
pub fn delete(&self, conn: &Connection) {
//find related notifications and delete them
Notification::find(conn, notification_kind::MENTION, self.id).map(|n| n.delete(conn));
diesel::delete(self).execute(conn).expect("Mention::delete: mention deletion error");
}
}
impl Notify<Connection> for Mention {
+4
View File
@@ -106,4 +106,8 @@ impl Notification {
});
json
}
pub fn delete(&self, conn: &Connection) {
diesel::delete(self).execute(conn).expect("Notification::delete: notification deletion error");
}
}