status: support either _misskey_quote or quoteUrl for fetching quotes

pull/36/head
Ariadne Conill 2022-12-25 04:51:21 +00:00
parent 8d86c77a58
commit 61565488a6
1 changed files with 15 additions and 2 deletions

View File

@ -126,7 +126,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
conversation: conversation_from_uri(@object['conversation']), conversation: conversation_from_uri(@object['conversation']),
media_attachment_ids: process_attachments.take(4).map(&:id), media_attachment_ids: process_attachments.take(4).map(&:id),
poll: process_poll, poll: process_poll,
quote: quote_from_url(@object['quoteUrl']), quote: process_quote,
} }
end end
end end
@ -428,10 +428,23 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
retry retry
end 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? return nil if url.nil?
quote = ResolveURLService.new.call(url) quote = ResolveURLService.new.call(url)
status_from_uri(quote.uri) if quote status_from_uri(quote.uri) if quote
rescue
nil
end end
end end