2
0

Prepend “RE: <url>” fallback link to Mastodon-authored quote posts (#35971)

This commit is contained in:
Claire
2025-09-03 11:35:44 +02:00
committed by GitHub
parent 927468bce5
commit 624c024766
3 changed files with 22 additions and 1 deletions

View File

@@ -44,6 +44,7 @@ class TextFormatter
end
html = simple_format(html, {}, sanitize: false).delete("\n") if multiline?
html = add_quote_fallback(html) if options[:quoted_status].present?
html.html_safe # rubocop:disable Rails/OutputSafety
end
@@ -172,4 +173,15 @@ class TextFormatter
def preloaded_accounts?
preloaded_accounts.present?
end
def add_quote_fallback(html)
return html if options[:quoted_status].nil?
url = ActivityPub::TagManager.instance.url_for(options[:quoted_status]) || ActivityPub::TagManager.instance.uri_for(options[:quoted_status])
return html if url.blank? || html.include?(url)
<<~HTML.squish
<p class="quote-inline">RE: #{TextFormatter.shortened_link(url)}</p>#{html}
HTML
end
end