mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-11 12:11:12 +00:00
Re-check suspension status on remote accounts on incoming activity
This commit is contained in:
parent
966b816382
commit
649d5fa194
|
@ -26,6 +26,9 @@ class ActivityPub::Activity::Announce < ActivityPub::Activity
|
||||||
|
|
||||||
Trends.register!(@status)
|
Trends.register!(@status)
|
||||||
|
|
||||||
|
# If we got a new reblog, the account is probably not suspended at origin anymore
|
||||||
|
@account.schedule_suspension_recheck!(interaction_time: @status.created_at)
|
||||||
|
|
||||||
distribute
|
distribute
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
process_tags
|
process_tags
|
||||||
process_audience
|
process_audience
|
||||||
|
|
||||||
|
# If we got a new status, the account is probably not suspended at origin anymore
|
||||||
|
@account.schedule_suspension_recheck!(interaction_time: @params[:created_at])
|
||||||
|
|
||||||
ApplicationRecord.transaction do
|
ApplicationRecord.transaction do
|
||||||
@status = Status.create!(@params)
|
@status = Status.create!(@params)
|
||||||
attach_tags(@status)
|
attach_tags(@status)
|
||||||
|
|
|
@ -8,6 +8,8 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
||||||
|
|
||||||
return if target_account.nil? || !target_account.local? || delete_arrived_first?(@json['id'])
|
return if target_account.nil? || !target_account.local? || delete_arrived_first?(@json['id'])
|
||||||
|
|
||||||
|
@account.schedule_suspension_recheck!
|
||||||
|
|
||||||
# Update id of already-existing follow requests
|
# Update id of already-existing follow requests
|
||||||
existing_follow_request = ::FollowRequest.find_by(account: @account, target_account: target_account)
|
existing_follow_request = ::FollowRequest.find_by(account: @account, target_account: target_account)
|
||||||
unless existing_follow_request.nil?
|
unless existing_follow_request.nil?
|
||||||
|
|
|
@ -6,6 +6,8 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
||||||
|
|
||||||
return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id']) || @account.favourited?(original_status)
|
return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id']) || @account.favourited?(original_status)
|
||||||
|
|
||||||
|
@account.schedule_suspension_recheck!
|
||||||
|
|
||||||
favourite = original_status.favourites.create!(account: @account)
|
favourite = original_status.favourites.create!(account: @account)
|
||||||
|
|
||||||
LocalNotificationWorker.perform_async(original_status.account_id, favourite.id, 'Favourite', 'favourite')
|
LocalNotificationWorker.perform_async(original_status.account_id, favourite.id, 'Favourite', 'favourite')
|
||||||
|
|
|
@ -64,6 +64,7 @@ class Account < ApplicationRecord
|
||||||
trust_level
|
trust_level
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SUSPENSION_REFRESH_INTERVAL = 1.day.freeze
|
||||||
BACKGROUND_REFRESH_INTERVAL = 1.week.freeze
|
BACKGROUND_REFRESH_INTERVAL = 1.week.freeze
|
||||||
REFRESH_DEADLINE = 6.hours
|
REFRESH_DEADLINE = 6.hours
|
||||||
STALE_THRESHOLD = 1.day
|
STALE_THRESHOLD = 1.day
|
||||||
|
@ -250,6 +251,14 @@ class Account < ApplicationRecord
|
||||||
AccountRefreshWorker.perform_in(rand(REFRESH_DEADLINE), id)
|
AccountRefreshWorker.perform_in(rand(REFRESH_DEADLINE), id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def schedule_suspension_recheck!(interaction_time: nil)
|
||||||
|
return unless suspended? && suspension_origin_remote?
|
||||||
|
return if last_webfingered_at.present? && last_webfingered_at >= SUSPENSION_REFRESH_INTERVAL.ago
|
||||||
|
return if interaction_time.present? && interaction_time < suspended_at
|
||||||
|
|
||||||
|
RemoteAccountRefreshWorker.perform_async(id)
|
||||||
|
end
|
||||||
|
|
||||||
def refresh!
|
def refresh!
|
||||||
ResolveAccountService.new.call(acct) unless local?
|
ResolveAccountService.new.call(acct) unless local?
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,17 +8,11 @@ class RemoteAccountRefreshWorker
|
||||||
sidekiq_options queue: 'pull', retry: 3
|
sidekiq_options queue: 'pull', retry: 3
|
||||||
|
|
||||||
def perform(id)
|
def perform(id)
|
||||||
account = Account.find_by(id: id)
|
account = Account.remote.find_by(id: id)
|
||||||
return if account.nil? || account.local?
|
return if account.nil?
|
||||||
|
|
||||||
ActivityPub::FetchRemoteAccountService.new.call(account.uri)
|
ActivityPub::FetchRemoteAccountService.new.call(account.uri)
|
||||||
rescue Mastodon::UnexpectedResponseError => e
|
rescue Mastodon::UnexpectedResponseError => e
|
||||||
response = e.response
|
raise e unless response_error_unsalvageable?(e.response)
|
||||||
|
|
||||||
if response_error_unsalvageable?(response)
|
|
||||||
# Give up
|
|
||||||
else
|
|
||||||
raise e
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user