* Add: #591 リモート保留中アカウントからメンションが来た場合にuriを記録し、承認時にフェッチしに行く処理 * Rename fetch_remove_status_worker.rb to fetch_remote_status_worker.rb * Wip * Add lock code
This commit is contained in:
parent
b2acc7dbb8
commit
2ab9ea642a
22 changed files with 307 additions and 15 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe EnableFollowRequestsService, type: :service do
|
||||
RSpec.describe ActivateFollowRequestsService, type: :service do
|
||||
subject { described_class.new.call(sender) }
|
||||
|
||||
let(:sender) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor') }
|
67
spec/services/activate_remote_statuses_service_spec.rb
Normal file
67
spec/services/activate_remote_statuses_service_spec.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivateRemoteStatusesService, type: :service do
|
||||
subject { described_class.new.call(sender) }
|
||||
|
||||
let(:sender) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor') }
|
||||
let(:alice) { Fabricate(:account) }
|
||||
let!(:pending_status) { Fabricate(:pending_status, account: sender, fetch_account: alice, uri: 'https://example.com/note') }
|
||||
|
||||
let(:payload) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: pending_status.uri,
|
||||
attributedTo: sender.uri,
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
to: 'https://www.w3.org/ns/activitystreams#Public',
|
||||
tag: [
|
||||
{
|
||||
type: 'Mention',
|
||||
href: ActivityPub::TagManager.instance.uri_for(alice),
|
||||
},
|
||||
],
|
||||
}
|
||||
end
|
||||
let(:json) { Oj.dump(payload) }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/note').to_return(status: 200, body: json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
context 'when has a pending status' do
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it 'original status is fetched', :sidekiq_inline do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.text).to eq 'Lorem ipsum'
|
||||
end
|
||||
|
||||
it 'pending request is removed' do
|
||||
expect { pending_status.reload }.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
|
||||
context 'when target_account is suspended' do
|
||||
before do
|
||||
alice.suspend!
|
||||
subject
|
||||
end
|
||||
|
||||
it 'original status is not fetched', :sidekiq_inline do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to be_nil
|
||||
end
|
||||
|
||||
it 'pending request is removed' do
|
||||
expect { pending_status.reload }.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
end
|
|
@ -48,6 +48,9 @@ RSpec.describe DeleteAccountService, type: :service do
|
|||
let!(:account_note) { Fabricate(:account_note, account: account) }
|
||||
|
||||
let!(:ng_rule_history) { Fabricate(:ng_rule_history, account: account) }
|
||||
let!(:pending_follow_request) { Fabricate(:pending_follow_request, account: account) }
|
||||
let!(:pending_status) { Fabricate(:pending_status, account: account, uri: 'https://example.com/note1') }
|
||||
let!(:fetchable_pending_status) { Fabricate(:pending_status, fetch_account: account, uri: 'https://example.com/note2') }
|
||||
|
||||
it 'deletes associated owned and target records and target notifications' do
|
||||
subject
|
||||
|
@ -77,6 +80,9 @@ RSpec.describe DeleteAccountService, type: :service do
|
|||
expect { circle_account.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect { circle_status.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect { bookmark_category_status.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect { pending_follow_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect { pending_status.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect { fetchable_pending_status.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
def expect_deletion_of_associated_owned_records
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue