From 61565488a6e6c4cadc5072b39a18dbde935d214a Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 25 Dec 2022 04:51:21 +0000 Subject: [PATCH] status: support either _misskey_quote or quoteUrl for fetching quotes --- app/lib/activitypub/activity/create.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 0dc315c53b1..47ab1b6963a 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -126,7 +126,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity conversation: conversation_from_uri(@object['conversation']), media_attachment_ids: process_attachments.take(4).map(&:id), poll: process_poll, - quote: quote_from_url(@object['quoteUrl']), + quote: process_quote, } end end @@ -428,10 +428,23 @@ class ActivityPub::Activity::Create < ActivityPub::Activity retry end - def quote_from_url(url) + def guess_quote_url + if @object["quoteUrl"] && !@object["quoteUrl"].empty? + @object["quoteUrl"] + elsif @object["_misskey_quote"] && !@object["_misskey_quote"].empty? + @object["_misskey_quote"] + else + nil + end + end + + def process_quote + url = guess_quote_url return nil if url.nil? quote = ResolveURLService.new.call(url) status_from_uri(quote.uri) if quote + rescue + nil end end