mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 01:41:08 +00:00
Relay reset delivery tracker model spec and callback (#36027)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
This commit is contained in:
parent
05a655f33e
commit
1b664cf20d
|
@ -34,7 +34,7 @@ class Relay < ApplicationRecord
|
|||
payload = Oj.dump(follow_activity(activity_id))
|
||||
|
||||
update!(state: :pending, follow_activity_id: activity_id)
|
||||
DeliveryFailureTracker.reset!(inbox_url)
|
||||
reset_delivery_tracker
|
||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||
end
|
||||
|
||||
|
@ -43,12 +43,16 @@ class Relay < ApplicationRecord
|
|||
payload = Oj.dump(unfollow_activity(activity_id))
|
||||
|
||||
update!(state: :idle, follow_activity_id: nil)
|
||||
DeliveryFailureTracker.reset!(inbox_url)
|
||||
reset_delivery_tracker
|
||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def reset_delivery_tracker
|
||||
DeliveryFailureTracker.reset!(inbox_url)
|
||||
end
|
||||
|
||||
def follow_activity(activity_id)
|
||||
{
|
||||
'@context': ActivityPub::TagManager::CONTEXT,
|
||||
|
|
|
@ -33,7 +33,7 @@ RSpec.describe Relay do
|
|||
|
||||
describe 'Callbacks' do
|
||||
describe 'Ensure disabled on destroy' do
|
||||
before { stub_delivery_worker }
|
||||
before { stub_services }
|
||||
|
||||
context 'when relay is enabled' do
|
||||
let(:relay) { Fabricate :relay, state: :accepted }
|
||||
|
@ -71,7 +71,7 @@ RSpec.describe Relay do
|
|||
describe '#disable' do
|
||||
let(:relay) { Fabricate :relay, state: :accepted, follow_activity_id: 'https://host.example/123' }
|
||||
|
||||
before { stub_delivery_worker }
|
||||
before { stub_services }
|
||||
|
||||
it 'changes state to idle and removes the activity id' do
|
||||
expect { relay.disable! }
|
||||
|
@ -79,13 +79,15 @@ RSpec.describe Relay do
|
|||
.and change { relay.reload.follow_activity_id }.to(be_nil)
|
||||
expect(ActivityPub::DeliveryWorker)
|
||||
.to have_received(:perform_async).with(match('Undo'), Account.representative.id, relay.inbox_url)
|
||||
expect(DeliveryFailureTracker)
|
||||
.to have_received(:reset!).with(relay.inbox_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#enable' do
|
||||
let(:relay) { Fabricate :relay, state: :idle, follow_activity_id: '' }
|
||||
|
||||
before { stub_delivery_worker }
|
||||
before { stub_services }
|
||||
|
||||
it 'changes state to pending and populates the activity id' do
|
||||
expect { relay.enable! }
|
||||
|
@ -93,10 +95,13 @@ RSpec.describe Relay do
|
|||
.and change { relay.reload.follow_activity_id }.to(be_present)
|
||||
expect(ActivityPub::DeliveryWorker)
|
||||
.to have_received(:perform_async).with(match('Follow'), Account.representative.id, relay.inbox_url)
|
||||
expect(DeliveryFailureTracker)
|
||||
.to have_received(:reset!).with(relay.inbox_url)
|
||||
end
|
||||
end
|
||||
|
||||
def stub_delivery_worker
|
||||
def stub_services
|
||||
allow(ActivityPub::DeliveryWorker).to receive(:perform_async)
|
||||
allow(DeliveryFailureTracker).to receive(:reset!)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user