Ignore error if mentioned account was not processable (#29215)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
f91f077985
commit
66b2bc1c84
4 changed files with 122 additions and 0 deletions
37
app/workers/mention_resolve_worker.rb
Normal file
37
app/workers/mention_resolve_worker.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MentionResolveWorker
|
||||
include Sidekiq::Worker
|
||||
include ExponentialBackoff
|
||||
include JsonLdHelper
|
||||
|
||||
sidekiq_options queue: 'pull', retry: 7
|
||||
|
||||
def perform(status_id, uri, options = {})
|
||||
status = Status.find_by(id: status_id)
|
||||
return if status.nil?
|
||||
|
||||
account = account_from_uri(uri)
|
||||
account = ActivityPub::FetchRemoteAccountService.new.call(uri, request_id: options[:request_id]) if account.nil?
|
||||
|
||||
return if account.nil?
|
||||
|
||||
status.mentions.create!(account: account, silent: false)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# Do nothing
|
||||
rescue Mastodon::UnexpectedResponseError => e
|
||||
response = e.response
|
||||
|
||||
if response_error_unsalvageable?(response)
|
||||
# Give up
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def account_from_uri(uri)
|
||||
ActivityPub::TagManager.instance.uri_to_resource(uri, Account)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue