Revert "Add block from bot follow settings"

This reverts commit ff994d78fa.
This commit is contained in:
KMY 2023-09-18 21:33:05 +09:00
parent ff994d78fa
commit cfa250421e
12 changed files with 13 additions and 208 deletions

View file

@ -49,16 +49,10 @@ RSpec.describe Api::V1::AccountsController do
describe 'POST #follow' do
let(:scopes) { 'write:follows' }
let(:my_actor_type) { 'Person' }
let(:lock_follow_from_bot) { false }
let(:other_account) { Fabricate(:account, username: 'bob', locked: locked) }
context 'when posting to an other account' do
before do
other_account.user.settings['lock_follow_from_bot'] = lock_follow_from_bot
other_account.user.save!
user.account.update!(actor_type: my_actor_type)
post :follow, params: { id: other_account.id }
end
@ -103,29 +97,6 @@ RSpec.describe Api::V1::AccountsController do
it_behaves_like 'forbidden for wrong scope', 'read:accounts'
end
context 'with unlocked account from bot' do
let(:locked) { false }
let(:lock_follow_from_bot) { true }
let(:my_actor_type) { 'Service' }
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns JSON with following=false and requested=true' do
json = body_as_json
expect(json[:following]).to be false
expect(json[:requested]).to be true
end
it 'creates a follow request relation between user and target user' do
expect(user.account.requested?(other_account)).to be true
end
it_behaves_like 'forbidden for wrong scope', 'read:accounts'
end
end
context 'when modifying follow options' do

View file

@ -3,8 +3,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::Activity::Follow do
let(:actor_type) { 'Person' }
let(:sender) { Fabricate(:account, domain: 'example.com', inbox_url: 'https://example.com/inbox', actor_type: actor_type) }
let(:sender) { Fabricate(:account, domain: 'example.com', inbox_url: 'https://example.com/inbox') }
let(:recipient) { Fabricate(:account) }
let(:json) do
@ -84,25 +83,6 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'when unlocked account but locked from bot' do
let(:actor_type) { 'Service' }
before do
recipient.user.settings['lock_follow_from_bot'] = true
recipient.user.save!
subject.perform
end
it 'does not create a follow from sender to recipient' do
expect(sender.following?(recipient)).to be false
end
it 'creates a follow request' do
expect(sender.requested?(recipient)).to be true
expect(sender.follow_requests.find_by(target_account: recipient).uri).to eq 'foo'
end
end
context 'when domain block reject_straight_follow' do
before do
Fabricate(:domain_block, domain: 'example.com', reject_straight_follow: true)

View file

@ -8,10 +8,9 @@ describe StatusReachFinder do
subject { described_class.new(status) }
let(:parent_status) { nil }
let(:in_reply_to_account_id) { nil }
let(:visibility) { :public }
let(:alice) { Fabricate(:account, username: 'alice') }
let(:status) { Fabricate(:status, account: alice, thread: parent_status, in_reply_to_account_id: in_reply_to_account_id, visibility: visibility) }
let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility) }
context 'with a simple case' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
@ -33,119 +32,6 @@ describe StatusReachFinder do
end
end
context 'with locking bot' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox', actor_type: 'Service') }
context 'with follower' do
before do
alice.user.settings['stop_deliver_to_bot'] = true
alice.user.save!
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
end
end
context 'with non-follower' do
it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
end
end
end
context 'with locking bot from misskey' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox', actor_type: 'Service') }
context 'with follower' do
before do
Fabricate(:instance_info, domain: 'foo.bar', software: 'misskey')
alice.user.settings['stop_deliver_to_bot'] = true
alice.user.save!
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
expect(subject.inboxes_for_misskey).to_not include 'https://foo.bar/inbox'
end
end
context 'with non-follower' do
it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
expect(subject.inboxes_for_misskey).to_not include 'https://foo.bar/inbox'
end
end
end
context 'with bot but not locking' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox', actor_type: 'Service') }
context 'with follower' do
before do
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
end
end
context 'with non-follower' do
it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
end
end
end
context 'with bot but mention' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox', actor_type: 'Service') }
let(:in_reply_to_account_id) { bob.id }
context 'with follower' do
before do
alice.user.settings['stop_deliver_to_bot'] = true
alice.user.save!
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
end
end
context 'with non-follower' do
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
end
end
end
context 'with bot but mention to status' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox', actor_type: 'Service') }
let(:parent_status) { Fabricate(:status, account: bob) }
context 'with follower' do
before do
alice.user.settings['stop_deliver_to_bot'] = true
alice.user.save!
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
end
end
context 'with non-follower' do
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
end
end
end
context 'when misskey case with unlisted post' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
let(:sender_software) { 'mastodon' }