diff --git a/app/lib/text_formatter.rb b/app/lib/text_formatter.rb index 48e2fc233..6a585d874 100644 --- a/app/lib/text_formatter.rb +++ b/app/lib/text_formatter.rb @@ -4,6 +4,7 @@ class TextFormatter include ActionView::Helpers::TextHelper include ERB::Util include RoutingHelper + include AccountsHelper URL_PREFIX_REGEX = /\A(https?:\/\/(www\.)?|xmpp:)/.freeze @@ -119,7 +120,8 @@ class TextFormatter return "@#{h(entity[:screen_name])}" if account.nil? url = ActivityPub::TagManager.instance.url_for(account) - display_username = same_username_hits&.positive? || with_domains? ? account.pretty_acct : account.username + # account may come from cache and has no display_name attribute because of .select(...) + display_username = same_username_hits&.positive? || with_domains? || !account.has_attribute?('display_name') ? account.pretty_acct : display_name(account) <<~HTML.squish @#{h(display_username)}