Send a notification when one of your article is reshared

Fixes #14
Fixes #19
This commit is contained in:
Bat 2018-05-24 11:03:37 +01:00
parent 0b098e539f
commit daf9120fba

View file

@ -444,6 +444,16 @@ impl Inbox for User {
// Notifications // Notifications
match act["type"].as_str().unwrap() { 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" => { "Follow" => {
let follower = User::from_url(conn, act["actor"].as_str().unwrap().to_string()).unwrap(); let follower = User::from_url(conn, act["actor"].as_str().unwrap().to_string()).unwrap();
Notification::insert(conn, NewNotification { Notification::insert(conn, NewNotification {