Don't unwrap()

This commit is contained in:
Kitaiti Makoto 2022-01-03 23:28:05 +09:00
parent 9d012c8f3c
commit ee6064eee8

View file

@ -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),