From d56ae182435316b2b208024d2a8b6080ffafb30f Mon Sep 17 00:00:00 2001 From: Bei Li <6008854+li-bei@users.noreply.github.com> Date: Thu, 11 Apr 2024 23:12:41 +0900 Subject: [PATCH] Add display_name to Web::NotificationSerializer --- app/serializers/web/notification_serializer.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/serializers/web/notification_serializer.rb b/app/serializers/web/notification_serializer.rb index fb2f7248a6..421e84cbb4 100644 --- a/app/serializers/web/notification_serializer.rb +++ b/app/serializers/web/notification_serializer.rb @@ -28,8 +28,12 @@ class Web::NotificationSerializer < ActiveModel::Serializer full_asset_url(object.from_account.avatar_static_url) end + def display_name + object.from_account.display_name.presence || object.from_account.username + end + def title - I18n.t("notification_mailer.#{object.type}.subject", name: object.from_account.display_name.presence || object.from_account.username) + I18n.t("notification_mailer.#{object.type}.subject", name: display_name) end def body