Remove local checks from formatter

This commit is contained in:
Fosco Marotto 2021-02-03 13:07:37 -05:00
parent 1def861fa0
commit c30f600f09
1 changed files with 19 additions and 18 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,14 +167,15 @@ class Formatter
end end
def plaintext(status) def plaintext(status)
return status.text if status.local? return status.text
#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 = account.local? ? linkify(account.note) : reformat(account.note) html = linkify(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
@ -202,7 +203,7 @@ class Formatter
end end
def format_field(account, str, **options) def format_field(account, str, **options)
html = account.local? ? encode_and_link_urls(str, me: true) : reformat(str) html = encode_and_link_urls(str, me: true)
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
@ -481,7 +482,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