Merge branch 'kb_development' into kb_migration
This commit is contained in:
commit
751b603e12
17 changed files with 341 additions and 44 deletions
|
@ -97,6 +97,22 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with domain block' do
|
||||
before do
|
||||
Fabricate(:account)
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let(:object_json) do
|
||||
ActivityPub::TagManager.instance.uri_for(status)
|
||||
end
|
||||
|
||||
it 'does not creates a reblog by sender of status', pending: 'considering spec' do
|
||||
expect(sender.reblogged?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the status belongs to a local user' do
|
||||
before do
|
||||
subject.perform
|
||||
|
|
|
@ -29,10 +29,11 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
subject { described_class.new(json, sender) }
|
||||
|
||||
let(:sender_software) { 'mastodon' }
|
||||
let(:custom_before) { false }
|
||||
|
||||
before do
|
||||
Fabricate(:instance_info, domain: 'example.com', software: sender_software)
|
||||
subject.perform
|
||||
subject.perform unless custom_before
|
||||
end
|
||||
|
||||
context 'when object has been edited' do
|
||||
|
@ -648,6 +649,80 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with mentions domain block reject_reply' do
|
||||
before do
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: :noop, reject_reply: true)
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let(:custom_before) { true }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
tag: [
|
||||
{
|
||||
type: 'Mention',
|
||||
href: ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
},
|
||||
],
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with mentions domain block reject_reply_exclude_followers' do
|
||||
before do
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: :noop, reject_reply_exclude_followers: true)
|
||||
recipient.follow!(sender) if follow
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let(:custom_before) { true }
|
||||
let(:follow) { false }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
tag: [
|
||||
{
|
||||
type: 'Mention',
|
||||
href: ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
},
|
||||
],
|
||||
}
|
||||
end
|
||||
|
||||
context 'when follower' do
|
||||
let(:follow) { true }
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not follower' do
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with media attachments' do
|
||||
let(:object_json) do
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Follow do
|
||||
let(:sender) { Fabricate(:account) }
|
||||
let(:sender) { Fabricate(:account, domain: 'example.com', inbox_url: 'https://example.com/inbox') }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
|
||||
let(:json) do
|
||||
|
@ -82,6 +82,35 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
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)
|
||||
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_new_follow' do
|
||||
before do
|
||||
Fabricate(:domain_block, domain: 'example.com', reject_new_follow: true)
|
||||
stub_request(:post, 'https://example.com/inbox').to_return(status: 200, body: '', headers: {})
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a follow from sender to recipient' do
|
||||
expect(sender.following?(recipient)).to be false
|
||||
expect(sender.requested?(recipient)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a follow relationship already exists' do
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Like do
|
||||
let(:sender) { Fabricate(:account) }
|
||||
let(:sender) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/') }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
let(:status) { Fabricate(:status, account: recipient) }
|
||||
|
||||
|
@ -28,4 +28,43 @@ RSpec.describe ActivityPub::Activity::Like do
|
|||
expect(sender.favourited?(status)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform when domain_block' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: :noop, reject_favourite: true)
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a favourite from sender to status' do
|
||||
expect(sender.favourited?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform when normal domain_block' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a favourite from sender to status', pending: 'considering spec' do
|
||||
expect(sender.favourited?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform when account domain_block' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
Fabricate(:account_domain_block, account: recipient, domain: 'example.com')
|
||||
subject.perform
|
||||
end
|
||||
|
||||
it 'does not create a favourite from sender to status', pending: 'considering spec' do
|
||||
expect(sender.favourited?(status)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -154,5 +154,67 @@ describe StatusReachFinder do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with extended domain block' do
|
||||
subject do
|
||||
described_class.new(status)
|
||||
end
|
||||
|
||||
before do
|
||||
bob.follow!(alice)
|
||||
tom.follow!(alice)
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: 'noop', **properties)
|
||||
end
|
||||
|
||||
let(:properties) { {} }
|
||||
let(:visibility) { :public }
|
||||
let(:searchability) { :public }
|
||||
let(:dissubscribable) { false }
|
||||
let(:spoiler_text) { '' }
|
||||
let(:status) { Fabricate(:status, account: alice, visibility: visibility, searchability: searchability, spoiler_text: spoiler_text) }
|
||||
let(:alice) { Fabricate(:account, username: 'alice', dissubscribable: dissubscribable) }
|
||||
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, uri: 'https://example.com/', inbox_url: 'https://example.com/inbox') }
|
||||
let(:tom) { Fabricate(:account, username: 'tom', domain: 'tom.com', protocol: :activitypub, uri: 'https://tom.com/', inbox_url: 'https://tom.com/inbox') }
|
||||
|
||||
context 'when reject_send_not_public_searchability' do
|
||||
let(:properties) { { reject_send_not_public_searchability: true } }
|
||||
let(:searchability) { :private }
|
||||
|
||||
it 'does not include the inbox of blocked domain' do
|
||||
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
||||
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when reject_send_public_unlisted' do
|
||||
let(:properties) { { reject_send_public_unlisted: true } }
|
||||
let(:visibility) { :public_unlisted }
|
||||
|
||||
it 'does not include the inbox of blocked domain' do
|
||||
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
||||
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
||||
end
|
||||
|
||||
context 'when reject_send_dissubscribable' do
|
||||
let(:properties) { { reject_send_dissubscribable: true } }
|
||||
let(:dissubscribable) { true }
|
||||
|
||||
it 'does not include the inbox of blocked domain' do
|
||||
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
||||
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when reject_send_sensitive' do
|
||||
let(:properties) { { reject_send_sensitive: true } }
|
||||
let(:spoiler_text) { 'CW' }
|
||||
|
||||
it 'does not include the inbox of blocked domain' do
|
||||
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
||||
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue