Skip to content

Commit

Permalink
status: support either _misskey_quote or quoteUrl for fetching quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
kaniini committed Dec 25, 2022
1 parent 8d86c77 commit 6156548
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/lib/activitypub/activity/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def process_status_params
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
Expand Down Expand Up @@ -428,10 +428,23 @@ def increment_voters_count!
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

0 comments on commit 6156548

Please sign in to comment.