One less unhandled error

This commit is contained in:
Bat 2018-06-10 11:01:02 +01:00
parent 87d39ba27f
commit 40d87e746d
1 changed files with 11 additions and 7 deletions

View File

@ -476,13 +476,17 @@ impl Inbox for User {
"Create" => {
match act["object"]["type"].as_str().unwrap() {
"Note" => {
let comment = Comment::find_by_ap_url(conn, act["object"]["id"].as_str().unwrap().to_string()).unwrap();
Notification::insert(conn, NewNotification {
title: format!("{} commented your article", comment.get_author(conn).display_name.clone()),
content: Some(comment.get_post(conn).title),
link: comment.ap_url,
user_id: self.id
});
match Comment::find_by_ap_url(conn, act["object"]["id"].as_str().unwrap().to_string()) {
Some(comment) => {
Notification::insert(conn, NewNotification {
title: format!("{} commented your article", comment.get_author(conn).display_name.clone()),
content: Some(comment.get_post(conn).title),
link: comment.ap_url,
user_id: self.id
});
},
None => println!("Couldn't find comment by AP id, to create a new notification")
};
}
_ => {}
}