From f2161a634099c7e58664eb7944e06e221a3d1e69 Mon Sep 17 00:00:00 2001 From: YoheiZuho Date: Mon, 26 Feb 2024 02:23:43 +0000 Subject: [PATCH] fix:quote not working --- app/helpers/formatting_helper.rb | 2 +- app/lib/activitypub/activity/create.rb | 10 ++++++++-- app/lib/activitypub/case_transform.rb | 9 ++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/helpers/formatting_helper.rb b/app/helpers/formatting_helper.rb index 3715fc27d..a10ca17fa 100644 --- a/app/helpers/formatting_helper.rb +++ b/app/helpers/formatting_helper.rb @@ -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 diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index b96b1289e..b8e3605bf 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -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{

RE:\s}.match(@object['content']) do |m| @object['content'] = @object['content'].sub(m[0], "#{m[0].sub(%r{}, '')}") end diff --git a/app/lib/activitypub/case_transform.rb b/app/lib/activitypub/case_transform.rb index bf5de7221..fae59bd53 100644 --- a/app/lib/activitypub/case_transform.rb +++ b/app/lib/activitypub/case_transform.rb @@ -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