Check for instance availability before attempting to fetch mentioned users

Port of db6b0a3b5d and d59d1d472e. Full credit goes to dwrss on GitHub.

Does NOT fix https://github.com/mastodon/mastodon/issues/22713.
This commit is contained in:
Jeremy Kescher 2023-01-15 21:19:41 +01:00
parent 004b2fc290
commit 560c06463d
No known key found for this signature in database
GPG key ID: 48DFE4BB15BA5940

View file

@ -222,8 +222,13 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
return if tag['href'].blank?
account = account_from_uri(tag['href'])
account = ActivityPub::FetchRemoteAccountService.new.call(tag['href'], request_id: @options[:request_id]) if account.nil?
begin
return unless account || DeliveryFailureTracker.available?(tag['href'])
account = ActivityPub::FetchRemoteAccountService.new.call(tag['href'], request_id: @options[:request_id]) if account.nil?
rescue HTTP::ConnectionError => e
Rails.logger.info "Fetching account #{tag['href']} failed: #{e}"
raise
end
return if account.nil?
@mentions << Mention.new(account: account, silent: false)