Skip to content

Commit

Permalink
Fix reblogs privacy (mastodon#10302)
Browse files Browse the repository at this point in the history
* Fix reblogs privacy

* Fix Announce processing specs
  • Loading branch information
ClearlyClaire authored and hiyuki2578 committed Oct 2, 2019
1 parent 92f95b9 commit 22fa1bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ def set_poll_id
end

def set_visibility
self.visibility = reblog.visibility if reblog? && visibility.nil?
self.visibility = (account.locked? ? :private : :public) if visibility.nil?
self.visibility = reblog.visibility if reblog?
self.sensitive = false if sensitive.nil?
end

Expand Down
1 change: 1 addition & 0 deletions spec/lib/activitypub/activity/announce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
type: 'Announce',
actor: 'https://example.com/actor',
object: object_json,
to: 'http://example.com/followers',
}.with_indifferent_access
end

Expand Down
21 changes: 21 additions & 0 deletions spec/services/reblog_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
RSpec.describe ReblogService, type: :service do
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) }

subject { ReblogService.new }

before do
subject.call(alice, status, visibility: reblog_visibility)
end

describe 'boosting privately' do
let(:reblog_visibility) { :private }

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

context 'OStatus' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', salmon_url: 'http://salmon.example.com') }
let(:status) { Fabricate(:status, account: bob, uri: 'tag:example.com;something:something') }
Expand Down

0 comments on commit 22fa1bd

Please sign in to comment.