fix:quote not working

This commit is contained in:
YoheiZuho 2024-02-26 02:23:43 +00:00
parent 14625836de
commit f2161a6340
3 changed files with 17 additions and 4 deletions

View File

@ -23,7 +23,7 @@ module FormattingHelper
status.text,
status.local?,
preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []),
quote: status.respond_to?(:quote) && status.quote
quote: status.respond_to?(:quote) && status.quote,
)
end

View File

@ -434,8 +434,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
def process_quote
return unless (@quote = quote_from_url(@object['quoteUrl']))
if @object.key?('quoteUrl')
url = @object['quoteUrl']
elsif @object.key?('quoteURL')
url = @object['quoteURL']
elsif @object.key?('_misskey_quote')
url = @object['_misskey_quote']
end
return unless (@quote = quote_from_url(url))
%r{<br><br>RE:\s</span><a.*</a>}.match(@object['content']) do |m|
@object['content'] = @object['content'].sub(m[0], "</span><span class=\"quote-inline\">#{m[0].sub(%r{</span>}, '')}</span>")
end

View File

@ -2,6 +2,11 @@
module ActivityPub::CaseTransform
class << self
NO_CONVERT_VALUES = %w(
_misskey_content
_misskey_quote
).freeze
def camel_lower_cache
@camel_lower_cache ||= {}
end
@ -12,7 +17,9 @@ module ActivityPub::CaseTransform
when Hash then value.deep_transform_keys! { |key| camel_lower(key) }
when Symbol then camel_lower(value.to_s).to_sym
when String
camel_lower_cache[value] ||= if value.start_with?('_:')
camel_lower_cache[value] ||= if NO_CONVERT_VALUES.include?(value)
value
elsif value.start_with?('_:')
"_:#{value.delete_prefix('_:').underscore.camelize(:lower)}"
elsif LanguagesHelper::ISO_639_1_REGIONAL.key?(value.to_sym)
value