From daf9120fbabf8901231cc2592a673a10d05f97b6 Mon Sep 17 00:00:00 2001 From: Bat Date: Thu, 24 May 2018 11:03:37 +0100 Subject: [PATCH] Send a notification when one of your article is reshared Fixes #14 Fixes #19 --- src/models/users.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/models/users.rs b/src/models/users.rs index dcfe2e9f..79c37ad9 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -444,6 +444,16 @@ impl Inbox for User { // Notifications match act["type"].as_str().unwrap() { + "Announce" => { + let actor = User::from_url(conn, act["actor"].as_str().unwrap().to_string()).unwrap(); + let post = Post::find_by_ap_url(conn, act["object"].as_str().unwrap().to_string()).unwrap(); + Notification::insert(conn, NewNotification { + title: format!("{} reshared your article", actor.display_name.clone()), + content: Some(post.title), + link: Some(post.ap_url), + user_id: self.id + }); + }, "Follow" => { let follower = User::from_url(conn, act["actor"].as_str().unwrap().to_string()).unwrap(); Notification::insert(conn, NewNotification {