mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 09:51:24 +00:00
Pull out repeated tracker reset to callback
This commit is contained in:
parent
04dbc4d19e
commit
41a25985c2
|
@ -23,6 +23,8 @@ class Relay < ApplicationRecord
|
||||||
|
|
||||||
before_destroy :ensure_disabled
|
before_destroy :ensure_disabled
|
||||||
|
|
||||||
|
after_save :reset_delivery_tracker, if: [:state_previously_changed?, :reset_failure_state?]
|
||||||
|
|
||||||
alias enabled? accepted?
|
alias enabled? accepted?
|
||||||
|
|
||||||
def to_log_human_identifier
|
def to_log_human_identifier
|
||||||
|
@ -34,7 +36,6 @@ class Relay < ApplicationRecord
|
||||||
payload = Oj.dump(follow_activity(activity_id))
|
payload = Oj.dump(follow_activity(activity_id))
|
||||||
|
|
||||||
update!(state: :pending, follow_activity_id: activity_id)
|
update!(state: :pending, follow_activity_id: activity_id)
|
||||||
DeliveryFailureTracker.reset!(inbox_url)
|
|
||||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,12 +44,19 @@ class Relay < ApplicationRecord
|
||||||
payload = Oj.dump(unfollow_activity(activity_id))
|
payload = Oj.dump(unfollow_activity(activity_id))
|
||||||
|
|
||||||
update!(state: :idle, follow_activity_id: nil)
|
update!(state: :idle, follow_activity_id: nil)
|
||||||
DeliveryFailureTracker.reset!(inbox_url)
|
|
||||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def reset_delivery_tracker
|
||||||
|
DeliveryFailureTracker.reset!(inbox_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_failure_state?
|
||||||
|
idle? || pending?
|
||||||
|
end
|
||||||
|
|
||||||
def follow_activity(activity_id)
|
def follow_activity(activity_id)
|
||||||
{
|
{
|
||||||
'@context': ActivityPub::TagManager::CONTEXT,
|
'@context': ActivityPub::TagManager::CONTEXT,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user