Skip to content

Commit

Permalink
#13 Turn searchability private if account is silenced
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Sep 24, 2023
1 parent a8f02d0 commit a9b2288
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def requires_review_notification?
def compute_searchability
local = account.local?

return 'private' if public_searchability? && account.silenced?
return 'direct' if unsupported_searchability?
return searchability if local && !searchability.nil?
return 'direct' if local || [:public, :private, :direct, :limited].exclude?(account.searchability.to_sym)
Expand Down
11 changes: 10 additions & 1 deletion spec/models/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,23 @@
let(:account_searchability) { :public }
let(:status_searchability) { :public }
let(:account_domain) { 'example.com' }
let(:account) { Fabricate(:account, domain: account_domain, searchability: account_searchability) }
let(:silenced_at) { nil }
let(:account) { Fabricate(:account, domain: account_domain, searchability: account_searchability, silenced_at: silenced_at) }

context 'when public-public' do
it 'returns public' do
expect(subject.compute_searchability).to eq 'public'
end
end

context 'when public-public but silenced' do
let(:silenced_at) { Time.now.utc }

it 'returns private' do
expect(subject.compute_searchability).to eq 'private'
end
end

context 'when public-private' do
let(:status_searchability) { :private }

Expand Down

0 comments on commit a9b2288

Please sign in to comment.