From 40d87e746d73f38d7311cd1423542b817e127fd9 Mon Sep 17 00:00:00 2001 From: Bat Date: Sun, 10 Jun 2018 11:01:02 +0100 Subject: [PATCH] One less unhandled error --- src/models/users.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/models/users.rs b/src/models/users.rs index 55b3f181..e15ed42d 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -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") + }; } _ => {} }