* Add: `conversations`テーブルに`ancestor_status`プロパティ * Fix test * Fix test more * Add: `limited_visibility`に`Reply`を追加、`context`のURI * Add: 外部からの`context`受信処理 * Fix test * Add: 公開範囲「返信」 * Fix test * Fix: 返信に返信以外の公開範囲を設定できない問題 * Add: ローカル投稿時にメンション追加・他サーバーへの転送 * Fix test * Fix test * Test: ローカルスレッドへの返信投稿の転送 * Test: 未知のアカウントからのメンション * Add: 編集・削除の連合に対応 * Remove: 重複テスト * Fix: 改善 * Add: 編集削除の転送処理・返信なのにsilentなメンションでの通知 * Fix: リプライが第三者に届かない問題 * Add: `always_sign_unsafe` * Add: Subject * Remove space * Fix: 他人のスレッドの送信先一覧を非表示 * Fix: おかしいコード
This commit is contained in:
parent
a52a8ce214
commit
a88349af55
42 changed files with 1115 additions and 77 deletions
|
@ -683,6 +683,84 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when status has a conversation' do
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
let(:status) { Fabricate(:status, account: alice, visibility: visibility, thread: parent_status, conversation: conversation) }
|
||||
let(:parent_status) { Fabricate(:status, account: bob, visibility: visibility, conversation: conversation) }
|
||||
let(:zilu) { Fabricate(:user, current_sign_in_at: last_active_at).account }
|
||||
let(:custom_before) { true }
|
||||
|
||||
before do
|
||||
zilu.follow!(alice)
|
||||
zilu.follow!(bob)
|
||||
Fabricate(:status, account: tom, visibility: visibility, conversation: conversation)
|
||||
Fabricate(:status, account: ohagi, visibility: visibility, conversation: conversation)
|
||||
status.mentions << Fabricate(:mention, account: bob, silent: true)
|
||||
status.mentions << Fabricate(:mention, account: ohagi, silent: true)
|
||||
status.mentions << Fabricate(:mention, account: zilu, silent: true)
|
||||
status.mentions << Fabricate(:mention, account: tom, silent: false)
|
||||
status.save
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
context 'when public visibility' do
|
||||
it 'does not create notification' do
|
||||
notification = Notification.find_by(account: bob, type: 'mention')
|
||||
|
||||
expect(notification).to be_nil
|
||||
end
|
||||
|
||||
it 'creates notification for active mention' do
|
||||
notification = Notification.find_by(account: tom, type: 'mention')
|
||||
|
||||
expect(notification).to_not be_nil
|
||||
expect(notification.mention.status_id).to eq status.id
|
||||
end
|
||||
|
||||
it 'inserts home feed for reply' do
|
||||
expect(home_feed_of(bob)).to include status.id
|
||||
end
|
||||
|
||||
it 'inserts home feed for non-replied but mentioned and following replied account' do
|
||||
expect(home_feed_of(zilu)).to include status.id
|
||||
end
|
||||
|
||||
it 'does not insert home feed for non-replied, non-following replied account but mentioned' do
|
||||
expect(home_feed_of(tom)).to_not include status.id
|
||||
end
|
||||
end
|
||||
|
||||
context 'when limited visibility' do
|
||||
let(:visibility) { :limited }
|
||||
|
||||
it 'creates notification' do
|
||||
notification = Notification.find_by(account: bob, type: 'mention')
|
||||
|
||||
expect(notification).to_not be_nil
|
||||
expect(notification.mention.status_id).to eq status.id
|
||||
end
|
||||
|
||||
it 'creates notification for other conversation account' do
|
||||
notification = Notification.find_by(account: ohagi, type: 'mention')
|
||||
|
||||
expect(notification).to_not be_nil
|
||||
expect(notification.mention.status_id).to eq status.id
|
||||
end
|
||||
|
||||
it 'inserts home feed for reply' do
|
||||
expect(home_feed_of(bob)).to include status.id
|
||||
end
|
||||
|
||||
it 'inserts home feed for non-replied but mentioned and following replied account' do
|
||||
expect(home_feed_of(zilu)).to include status.id
|
||||
end
|
||||
|
||||
it 'does not insert home feed for non-replied, non-following replied account but mentioned' do
|
||||
expect(home_feed_of(tom)).to_not include status.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when updated status is already boosted or quoted' do
|
||||
let(:custom_before) { true }
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ RSpec.describe PostStatusService, type: :service do
|
|||
expect(status.limited_scope).to eq 'circle'
|
||||
end
|
||||
|
||||
it 'limited visibility and empty circle' do
|
||||
it 'limited visibility without circle' do
|
||||
account = Fabricate(:account)
|
||||
text = 'This is an English text.'
|
||||
|
||||
|
@ -295,6 +295,158 @@ RSpec.describe PostStatusService, type: :service do
|
|||
expect(status.mentioned_accounts.count).to eq 1
|
||||
end
|
||||
|
||||
describe 'create a new response status to limited post' do
|
||||
it 'when reply visibility' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
account = Fabricate(:account)
|
||||
text = 'test status update'
|
||||
|
||||
status = subject.call(account, text: text, thread: in_reply_to_status, visibility: 'reply')
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.thread).to eq in_reply_to_status
|
||||
expect(status.visibility).to eq 'limited'
|
||||
expect(status.limited_scope).to eq 'reply'
|
||||
end
|
||||
|
||||
it 'when limited visibility' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
account = Fabricate(:account)
|
||||
text = 'test status update'
|
||||
|
||||
status = subject.call(account, text: text, thread: in_reply_to_status, visibility: 'limited')
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.thread).to eq in_reply_to_status
|
||||
expect(status.visibility).to eq 'limited'
|
||||
expect(status.limited_scope).to eq 'reply'
|
||||
end
|
||||
|
||||
it 'when circle visibility' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
account = Fabricate(:account)
|
||||
text = 'test status update'
|
||||
|
||||
circle = Fabricate(:circle, account: account)
|
||||
circle_account = Fabricate(:account)
|
||||
circle_account.follow!(account)
|
||||
circle.accounts << circle_account
|
||||
circle.save!
|
||||
|
||||
status = subject.call(account, text: text, thread: in_reply_to_status, visibility: 'circle', circle_id: circle.id)
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.thread).to eq in_reply_to_status
|
||||
expect(status.visibility).to eq 'limited'
|
||||
expect(status.limited_scope).to eq 'circle'
|
||||
expect(status.mentioned_accounts.pluck(:id)).to eq [circle_account.id]
|
||||
end
|
||||
|
||||
it 'when public visibility' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
account = Fabricate(:account)
|
||||
text = 'test status update'
|
||||
|
||||
status = subject.call(account, text: text, thread: in_reply_to_status, visibility: :public)
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.thread).to eq in_reply_to_status
|
||||
expect(status.visibility).to eq 'public'
|
||||
end
|
||||
|
||||
it 'when direct visibility' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
account = Fabricate(:account)
|
||||
text = 'test status update'
|
||||
|
||||
status = subject.call(account, text: text, thread: in_reply_to_status, visibility: :direct)
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.thread).to eq in_reply_to_status
|
||||
expect(status.visibility).to eq 'direct'
|
||||
end
|
||||
|
||||
it 'duplicate replies' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
in_reply_to_status.mentions.create!(account: Fabricate(:account))
|
||||
|
||||
status = subject.call(Fabricate(:user).account, text: 'Ohagi is good', thread: in_reply_to_status, visibility: 'reply')
|
||||
|
||||
thread_account_ids = [in_reply_to_status.account, in_reply_to_status.mentions.first.account].map(&:id)
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.conversation_id).to eq in_reply_to_status.conversation_id
|
||||
expect(status.conversation.ancestor_status_id).to eq in_reply_to_status.id
|
||||
expect(status.mentions.pluck(:account_id)).to match_array thread_account_ids
|
||||
end
|
||||
|
||||
it 'duplicate reply-to-reply' do
|
||||
ancestor_account = Fabricate(:account, username: 'ancestor', domain: nil)
|
||||
reply_account = Fabricate(:account)
|
||||
|
||||
first_status = Fabricate(:status, account: ancestor_account, visibility: :limited)
|
||||
in_reply_to_status = subject.call(reply_account, text: 'Ohagi is good, @ancestor', thread: first_status, visibility: 'reply')
|
||||
status = subject.call(ancestor_account, text: 'Ohagi is good', thread: in_reply_to_status, visibility: 'reply')
|
||||
|
||||
thread_account_ids = [ancestor_account, reply_account].map(&:id)
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.conversation_id).to eq in_reply_to_status.conversation_id
|
||||
expect(status.conversation_id).to eq first_status.conversation_id
|
||||
expect(status.conversation.ancestor_status_id).to eq first_status.id
|
||||
expect(status.mentions.pluck(:account_id)).to match_array thread_account_ids
|
||||
end
|
||||
|
||||
it 'duplicate reply-to-third_reply' do
|
||||
first_status = Fabricate(:status, visibility: :limited)
|
||||
first_status.mentions.create!(account: Fabricate(:account))
|
||||
|
||||
mentioned_account = Fabricate(:account, username: 'ohagi', domain: nil)
|
||||
mentioned_account2 = Fabricate(:account, username: 'bob', domain: nil)
|
||||
in_reply_to_status = subject.call(Fabricate(:user).account, text: 'Ohagi is good, @ohagi', thread: first_status, visibility: 'reply')
|
||||
status = subject.call(Fabricate(:user).account, text: 'Ohagi is good, @bob', thread: in_reply_to_status, visibility: 'reply')
|
||||
|
||||
thread_account_ids = [first_status.account, first_status.mentions.first.account, mentioned_account, mentioned_account2, in_reply_to_status.account].map(&:id)
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.conversation_id).to eq in_reply_to_status.conversation_id
|
||||
expect(status.conversation_id).to eq first_status.conversation_id
|
||||
expect(status.conversation.ancestor_status_id).to eq first_status.id
|
||||
expect(status.mentions.pluck(:account_id)).to match_array thread_account_ids
|
||||
end
|
||||
|
||||
it 'do not duplicate replies when limited post' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
in_reply_to_status.mentions.create!(account: Fabricate(:account))
|
||||
|
||||
status = subject.call(Fabricate(:user).account, text: 'Ohagi is good', thread: in_reply_to_status, visibility: 'mutual')
|
||||
|
||||
[in_reply_to_status.account, in_reply_to_status.mentions.first.account].map(&:id)
|
||||
|
||||
expect(status).to be_persisted
|
||||
expect(status.limited_scope).to eq 'personal'
|
||||
|
||||
mentions = status.mentions.pluck(:account_id)
|
||||
expect(mentions).to_not include in_reply_to_status.account_id
|
||||
expect(mentions).to_not include in_reply_to_status.mentions.first.account_id
|
||||
end
|
||||
|
||||
it 'do not duplicate replies when not limited post' do
|
||||
in_reply_to_status = Fabricate(:status, visibility: :limited)
|
||||
in_reply_to_status.mentions.create!(account: Fabricate(:account))
|
||||
|
||||
status = subject.call(Fabricate(:user).account, text: 'Ohagi is good', thread: in_reply_to_status, visibility: 'public')
|
||||
|
||||
[in_reply_to_status.account, in_reply_to_status.mentions.first.account].map(&:id)
|
||||
|
||||
expect(status).to be_persisted
|
||||
|
||||
mentions = status.mentions.pluck(:account_id)
|
||||
expect(mentions).to_not include in_reply_to_status.account_id
|
||||
expect(mentions).to_not include in_reply_to_status.mentions.first.account_id
|
||||
end
|
||||
end
|
||||
|
||||
it 'safeguards mentions' do
|
||||
account = Fabricate(:account)
|
||||
mentioned_account = Fabricate(:account, username: 'alice')
|
||||
|
|
|
@ -8,12 +8,14 @@ RSpec.describe RemoveStatusService, type: :service do
|
|||
let!(:alice) { Fabricate(:account) }
|
||||
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
||||
let!(:jeff) { Fabricate(:account) }
|
||||
let!(:hank) { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
let!(:bill) { Fabricate(:account, username: 'bill', protocol: :activitypub, domain: 'example2.com', inbox_url: 'http://example2.com/inbox') }
|
||||
let!(:hank) { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', shared_inbox_url: 'http://example.com/inbox', inbox_url: 'http://example.com/hank/inbox') }
|
||||
let!(:bill) { Fabricate(:account, username: 'bill', protocol: :activitypub, domain: 'example2.com', shared_inbox_url: 'http://example2.com/inbox', inbox_url: 'http://example2.com/bill/inbox') }
|
||||
|
||||
before do
|
||||
stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
|
||||
stub_request(:post, 'http://example.com/hank/inbox').to_return(status: 200)
|
||||
stub_request(:post, 'http://example2.com/inbox').to_return(status: 200)
|
||||
stub_request(:post, 'http://example2.com/bill/inbox').to_return(status: 200)
|
||||
|
||||
jeff.follow!(alice)
|
||||
hank.follow!(alice)
|
||||
|
@ -72,6 +74,57 @@ RSpec.describe RemoveStatusService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when removed status is limited' do
|
||||
let(:status) { PostStatusService.new.call(alice, visibility: 'mutual', text: 'limited post') }
|
||||
|
||||
before do
|
||||
status.mentions << Fabricate(:mention, account: hank, silent: true)
|
||||
end
|
||||
|
||||
it 'sends Delete activity to followers' do
|
||||
subject.call(status)
|
||||
expect(a_request(:post, 'http://example.com/inbox').with(
|
||||
body: hash_including({
|
||||
'type' => 'Delete',
|
||||
'object' => {
|
||||
'type' => 'Tombstone',
|
||||
'id' => ActivityPub::TagManager.instance.uri_for(status),
|
||||
'atomUri' => OStatus::TagManager.instance.uri_for(status),
|
||||
},
|
||||
})
|
||||
)).to have_been_made.once
|
||||
end
|
||||
end
|
||||
|
||||
context 'when removed status is limited and remote conversation' do
|
||||
let(:status) { PostStatusService.new.call(alice, visibility: 'mutual', text: 'limited post') }
|
||||
|
||||
before do
|
||||
status.conversation.update(uri: 'http://example2.com/conversation', inbox_url: 'http://example2.com/bill/inbox')
|
||||
status.mentions << Fabricate(:mention, account: hank, silent: true)
|
||||
end
|
||||
|
||||
it 'sends Delete activity to conversation' do
|
||||
subject.call(status)
|
||||
expect(a_request(:post, 'http://example2.com/bill/inbox').with(
|
||||
body: hash_including({
|
||||
'type' => 'Delete',
|
||||
'object' => {
|
||||
'type' => 'Tombstone',
|
||||
'id' => ActivityPub::TagManager.instance.uri_for(status),
|
||||
'atomUri' => OStatus::TagManager.instance.uri_for(status),
|
||||
},
|
||||
})
|
||||
)).to have_been_made.once
|
||||
end
|
||||
|
||||
it 'do not send Delete activity to followers' do
|
||||
subject.call(status)
|
||||
expect(a_request(:post, 'http://example.com/hank/inbox')).to_not have_been_made
|
||||
expect(a_request(:post, 'http://example.com/inbox')).to_not have_been_made
|
||||
end
|
||||
end
|
||||
|
||||
context 'when removed status is a private self-reblog' do
|
||||
let!(:original_status) { Fabricate(:status, account: alice, text: 'Hello ThisIsASecret', visibility: :private) }
|
||||
let!(:status) { ReblogService.new.call(alice, original_status) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue