Refactor notifications

This commit is contained in:
Bat
2018-07-26 15:46:10 +02:00
parent 44172b67d5
commit c87d490664
12 changed files with 146 additions and 46 deletions
+2 -6
View File
@@ -89,15 +89,11 @@ impl FromActivity<activity::Like, PgConnection> for Like {
impl Notify<PgConnection> for Like {
fn notify(&self, conn: &PgConnection) {
let liker = User::get(conn, self.user_id).unwrap();
let post = Post::get(conn, self.post_id).unwrap();
for author in post.get_authors(conn) {
let post = post.clone();
Notification::insert(conn, NewNotification {
title: "{{ data }} liked your article".to_string(),
data: Some(liker.display_name.clone()),
content: Some(post.title),
link: Some(post.ap_url),
kind: notification_kind::LIKE.to_string(),
object_id: self.id,
user_id: author.id
});
}