Browse Source

show display_name for mention

closed-social-glitch-2
欧醚 1 year ago
parent
commit
70e87a1fc9
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      app/lib/text_formatter.rb

+ 3
- 1
app/lib/text_formatter.rb View File

@ -4,6 +4,7 @@ class TextFormatter
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper
include ERB::Util include ERB::Util
include RoutingHelper include RoutingHelper
include AccountsHelper
URL_PREFIX_REGEX = /\A(https?:\/\/(www\.)?|xmpp:)/.freeze URL_PREFIX_REGEX = /\A(https?:\/\/(www\.)?|xmpp:)/.freeze
@ -119,7 +120,8 @@ class TextFormatter
return "@#{h(entity[:screen_name])}" if account.nil? return "@#{h(entity[:screen_name])}" if account.nil?
url = ActivityPub::TagManager.instance.url_for(account) 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 <<~HTML.squish
<span class="h-card"><a href="#{h(url)}" class="u-url mention">@<span>#{h(display_username)}</span></a></span> <span class="h-card"><a href="#{h(url)}" class="u-url mention">@<span>#{h(display_username)}</span></a></span>

Loading…
Cancel
Save