#38 Change limited_scope to circle when personal post is added mentions
This commit is contained in:
parent
b1759f2c10
commit
62b7b7a9b9
3 changed files with 53 additions and 1 deletions
|
@ -167,7 +167,13 @@ class UpdateStatusService < BaseService
|
||||||
|
|
||||||
def update_metadata!
|
def update_metadata!
|
||||||
ProcessHashtagsService.new.call(@status)
|
ProcessHashtagsService.new.call(@status)
|
||||||
ProcessMentionsService.new.call(@status)
|
process_mentions_service.call(@status)
|
||||||
|
|
||||||
|
@status.update(limited_scope: :circle) if process_mentions_service.mentions?
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_mentions_service
|
||||||
|
@process_mentions_service ||= ProcessMentionsService.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcast_updates!
|
def broadcast_updates!
|
||||||
|
|
|
@ -250,6 +250,19 @@ RSpec.describe PostStatusService, type: :service do
|
||||||
expect(status.mentioned_accounts.count).to eq 0
|
expect(status.mentioned_accounts.count).to eq 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'using empty circle but with mention' do
|
||||||
|
account = Fabricate(:account)
|
||||||
|
Fabricate(:account, username: 'bob', domain: nil)
|
||||||
|
circle = Fabricate(:circle, account: account)
|
||||||
|
text = 'This is an English text. @bob'
|
||||||
|
|
||||||
|
status = subject.call(account, text: text, visibility: 'circle', circle_id: circle.id)
|
||||||
|
|
||||||
|
expect(status.visibility).to eq 'limited'
|
||||||
|
expect(status.limited_scope).to eq 'circle'
|
||||||
|
expect(status.mentioned_accounts.count).to eq 1
|
||||||
|
end
|
||||||
|
|
||||||
it 'safeguards mentions' do
|
it 'safeguards mentions' do
|
||||||
account = Fabricate(:account)
|
account = Fabricate(:account)
|
||||||
mentioned_account = Fabricate(:account, username: 'alice')
|
mentioned_account = Fabricate(:account, username: 'alice')
|
||||||
|
|
|
@ -166,6 +166,39 @@ RSpec.describe UpdateStatusService, type: :service do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when personal_limited mentions in text change' do
|
||||||
|
let!(:account) { Fabricate(:account) }
|
||||||
|
let!(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
let!(:status) { PostStatusService.new.call(account, text: 'Hello', visibility: 'circle', circle_id: Fabricate(:circle, account: account).id) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
subject.call(status, status.account_id, text: 'Hello @bob')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'changes mentions' do
|
||||||
|
expect(status.active_mentions.pluck(:account_id)).to eq [bob.id]
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'changes visibilities' do
|
||||||
|
expect(status.visibility).to eq 'limited'
|
||||||
|
expect(status.limited_scope).to eq 'circle'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when personal_limited in text change' do
|
||||||
|
let!(:account) { Fabricate(:account) }
|
||||||
|
let!(:status) { PostStatusService.new.call(account, text: 'Hello', visibility: 'circle', circle_id: Fabricate(:circle, account: account).id) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
subject.call(status, status.account_id, text: 'AAA')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'not changing visibilities' do
|
||||||
|
expect(status.visibility).to eq 'limited'
|
||||||
|
expect(status.limited_scope).to eq 'personal'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when hashtags in text change' do
|
context 'when hashtags in text change' do
|
||||||
let!(:account) { Fabricate(:account) }
|
let!(:account) { Fabricate(:account) }
|
||||||
let!(:status) { PostStatusService.new.call(account, text: 'Hello #foo') }
|
let!(:status) { PostStatusService.new.call(account, text: 'Hello #foo') }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue