Revert "Remove local checks from formatter"

This reverts commit c30f600f09.
This commit is contained in:
Fosco Marotto 2021-02-03 13:14:22 -05:00
parent e4a214a0c4
commit 8d9db14121
1 changed files with 18 additions and 19 deletions

View File

@ -115,11 +115,11 @@ class Formatter
return '' if raw_content.blank? return '' if raw_content.blank?
# unless status.local? unless status.local?
# html = reformat(raw_content) html = reformat(raw_content)
# html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify] html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify]
# return html.html_safe # rubocop:disable Rails/OutputSafety return html.html_safe # rubocop:disable Rails/OutputSafety
# end end
linkable_accounts = status.active_mentions.map(&:account) linkable_accounts = status.active_mentions.map(&:account)
linkable_accounts << status.account linkable_accounts << status.account
@ -167,15 +167,14 @@ class Formatter
end end
def plaintext(status) def plaintext(status)
return status.text return status.text if status.local?
#if status.local?
#text = status.text.gsub(/(<br \/>|<br>|<\/p>)+/) { |match| "#{match}\n" } text = status.text.gsub(/(<br \/>|<br>|<\/p>)+/) { |match| "#{match}\n" }
#strip_tags(text) strip_tags(text)
end end
def simplified_format(account, **options) def simplified_format(account, **options)
html = linkify(account.note) html = account.local? ? linkify(account.note) : reformat(account.note)
html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify] html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify]
html.html_safe # rubocop:disable Rails/OutputSafety html.html_safe # rubocop:disable Rails/OutputSafety
end end
@ -203,7 +202,7 @@ class Formatter
end end
def format_field(account, str, **options) def format_field(account, str, **options)
html = encode_and_link_urls(str, me: true) html = account.local? ? encode_and_link_urls(str, me: true) : reformat(str)
html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify] html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify]
html.html_safe # rubocop:disable Rails/OutputSafety html.html_safe # rubocop:disable Rails/OutputSafety
end end
@ -482,7 +481,7 @@ class Formatter
end end
def mention_html(account) def mention_html(account)
# return "<span>@#{encode(account.acct)}</span>" unless account.local? return "<span>@#{encode(account.acct)}</span>" unless account.local?
"<a data-focusable=\"true\" role=\"link\" href=\"#{encode(TagManager.instance.url_for(account))}\" class=\"u-url mention\">@#{encode(account.acct)}</a>" "<a data-focusable=\"true\" role=\"link\" href=\"#{encode(TagManager.instance.url_for(account))}\" class=\"u-url mention\">@#{encode(account.acct)}</a>"
end end