Skip to content

Commit

Permalink
Prevent from publicly boosting one's own private toots (mastodon#10775)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and Gargron committed May 17, 2019
1 parent d743217 commit a04664b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/services/reblog_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def call(account, reblogged_status, options = {})

return reblog unless reblog.nil?

reblog = account.statuses.create!(reblog: reblogged_status, text: '', visibility: options[:visibility] || account.user&.setting_default_privacy)
visibility = options[:visibility] || account.user&.setting_default_privacy
visibility = reblogged_status.visibility if reblogged_status.hidden?
reblog = account.statuses.create!(reblog: reblogged_status, text: '', visibility: visibility)

DistributionWorker.perform_async(reblog.id)
Pubsubhubbub::DistributionWorker.perform_async(reblog.stream_entry.id)
Expand Down
12 changes: 10 additions & 2 deletions spec/services/reblog_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
let(:alice) { Fabricate(:account, username: 'alice') }

context 'creates a reblog with appropriate visibility' do
let(:bob) { Fabricate(:account, username: 'bob') }
let(:visibility) { :public }
let(:reblog_visibility) { :public }
let(:status) { Fabricate(:status, account: bob, visibility: visibility) }
let(:status) { Fabricate(:status, account: alice, visibility: visibility) }

subject { ReblogService.new }

Expand All @@ -22,6 +21,15 @@
expect(status.reblogs.first.visibility).to eq 'private'
end
end

describe 'public reblogs of private toots should remain private' do
let(:visibility) { :private }
let(:reblog_visibility) { :public }

it 'reblogs privately' do
expect(status.reblogs.first.visibility).to eq 'private'
end
end
end

context 'OStatus' do
Expand Down

0 comments on commit a04664b

Please sign in to comment.