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 1/2] 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 fb2f7248a6d..421e84cbb4b 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 From 33c1e2858e667e6591996f4451cb01b9e99a87db Mon Sep 17 00:00:00 2001 From: Bei Li <6008854+li-bei@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:47:01 +0900 Subject: [PATCH 2/2] Add :display_name --- app/serializers/web/notification_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/serializers/web/notification_serializer.rb b/app/serializers/web/notification_serializer.rb index 421e84cbb4b..6acc7a4ac78 100644 --- a/app/serializers/web/notification_serializer.rb +++ b/app/serializers/web/notification_serializer.rb @@ -6,7 +6,7 @@ class Web::NotificationSerializer < ActiveModel::Serializer include ActionView::Helpers::SanitizeHelper attributes :access_token, :preferred_locale, :notification_id, - :notification_type, :icon, :title, :body + :notification_type, :icon, :display_name, :title, :body def access_token current_push_subscription.associated_access_token