mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 01:41:08 +00:00
Prepend “RE: <url>” fallback link to Mastodon-authored quote posts (#35971)
This commit is contained in:
parent
927468bce5
commit
624c024766
|
@ -27,7 +27,9 @@ module FormattingHelper
|
||||||
module_function :extract_status_plain_text
|
module_function :extract_status_plain_text
|
||||||
|
|
||||||
def status_content_format(status)
|
def status_content_format(status)
|
||||||
html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []))
|
quoted_status = status.quote&.quoted_status if status.local?
|
||||||
|
|
||||||
|
html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []), quoted_status: quoted_status)
|
||||||
end
|
end
|
||||||
|
|
||||||
def rss_status_content_format(status)
|
def rss_status_content_format(status)
|
||||||
|
|
|
@ -44,6 +44,7 @@ class TextFormatter
|
||||||
end
|
end
|
||||||
|
|
||||||
html = simple_format(html, {}, sanitize: false).delete("\n") if multiline?
|
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
|
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
@ -172,4 +173,15 @@ class TextFormatter
|
||||||
def preloaded_accounts?
|
def preloaded_accounts?
|
||||||
preloaded_accounts.present?
|
preloaded_accounts.present?
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -45,6 +45,13 @@ class StatusEdit < ApplicationRecord
|
||||||
delegate :local?, :application, :edited?, :edited_at,
|
delegate :local?, :application, :edited?, :edited_at,
|
||||||
:discarded?, :reply?, :visibility, :language, to: :status
|
:discarded?, :reply?, :visibility, :language, to: :status
|
||||||
|
|
||||||
|
def quote
|
||||||
|
underlying_quote = status.quote
|
||||||
|
return if underlying_quote.nil? || underlying_quote.id != quote_id
|
||||||
|
|
||||||
|
underlying_quote
|
||||||
|
end
|
||||||
|
|
||||||
def with_media?
|
def with_media?
|
||||||
ordered_media_attachments.any?
|
ordered_media_attachments.any?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user