From ee6064eee8fe2d6b5eb5c6bc6abef9f64e694bd2 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 3 Jan 2022 23:28:05 +0900 Subject: [PATCH] Don't unwrap() --- src/template_utils.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/template_utils.rs b/src/template_utils.rs index 9266aa52..de1e18ac 100644 --- a/src/template_utils.rs +++ b/src/template_utils.rs @@ -100,7 +100,9 @@ macro_rules! render { } pub fn translate_notification(ctx: BaseContext<'_>, notif: Notification) -> String { - let name = notif.get_actor(ctx.0).unwrap().name(); + let name = notif + .get_actor(ctx.0) + .map_or_else(|_| i18n!(ctx.1, "Someone"), |user| user.name()); match notif.kind.as_ref() { notification_kind::COMMENT => i18n!(ctx.1, "{0} commented on your article."; &name), notification_kind::FOLLOW => i18n!(ctx.1, "{0} is subscribed to you."; &name),