parent
7a6ec3603e
commit
294acdfd94
4 changed files with 29 additions and 26 deletions
|
@ -147,7 +147,7 @@ class ActivityPub::Parser::StatusParser
|
|||
def audience_searchable_by
|
||||
return nil if @object['searchableBy'].nil?
|
||||
|
||||
@audience_searchable_by = as_array(@object['searchableBy']).map { |x| value_or_id(x) }
|
||||
@audience_searchable_by = as_array(@object['searchableBy']).map { |x| value_or_id(x) }.compact_blank
|
||||
end
|
||||
|
||||
def summary_language_map?
|
||||
|
@ -204,17 +204,18 @@ class ActivityPub::Parser::StatusParser
|
|||
|
||||
def searchability_from_audience
|
||||
return nil if audience_searchable_by.blank?
|
||||
return :limited if audience_searchable_by.include?('kmyblue:Limited') || audience_searchable_by.include?('as:Limited')
|
||||
|
||||
if audience_searchable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) }
|
||||
:public
|
||||
elsif audience_searchable_by.include?('kmyblue:Limited') || audience_searchable_by.include?('as:Limited')
|
||||
:limited
|
||||
elsif audience_searchable_by.include?('kmyblue:LocalPublic') && @friend
|
||||
:public_unlisted
|
||||
elsif audience_searchable_by.include?(@account.followers_url)
|
||||
:private
|
||||
elsif audience_searchable_by.include?(@account.uri) || audience_searchable_by.include?(@account.url)
|
||||
:direct
|
||||
else
|
||||
:limited
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -278,7 +278,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
def audience_searchable_by
|
||||
return nil if @json['searchableBy'].nil?
|
||||
|
||||
@audience_searchable_by_processaccountservice = as_array(@json['searchableBy']).map { |x| value_or_id(x) }
|
||||
@audience_searchable_by_processaccountservice = as_array(@json['searchableBy']).map { |x| value_or_id(x) }.compact_blank
|
||||
end
|
||||
|
||||
def searchability_from_audience
|
||||
|
@ -289,14 +289,16 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
return invalid_subscription_software? ? misskey_searchability_from_indexable : :direct
|
||||
end
|
||||
|
||||
return :limited if audience_searchable_by.include?('kmyblue:Limited') || audience_searchable_by.include?('as:Limited')
|
||||
|
||||
if audience_searchable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) }
|
||||
:public
|
||||
elsif audience_searchable_by.include?(@account.followers_url)
|
||||
:private
|
||||
elsif audience_searchable_by.include?('kmyblue:Limited') || audience_searchable_by.include?('as:Limited')
|
||||
:limited
|
||||
else
|
||||
elsif audience_searchable_by.include?(@account.uri) || audience_searchable_by.include?(@account.url)
|
||||
:direct
|
||||
else
|
||||
:limited
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -653,6 +653,17 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with unintended value' do
|
||||
let(:searchable_by) { 'ohagi' }
|
||||
|
||||
it 'create status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.searchability).to eq 'limited'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with direct when not specify' do
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
|
@ -675,17 +686,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with limited old spec' do
|
||||
let(:searchable_by) { 'as:Limited' }
|
||||
|
||||
it 'create status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.searchability).to eq 'limited'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with bio' do
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
|
|
|
@ -165,14 +165,6 @@ RSpec.describe ActivityPub::ProcessAccountService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when limited old spec' do
|
||||
let(:searchable_by) { 'as:Limited' }
|
||||
|
||||
it 'searchability is limited' do
|
||||
expect(subject.searchability).to eq 'limited'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when empty array' do
|
||||
let(:searchable_by) { '' }
|
||||
|
||||
|
@ -181,6 +173,14 @@ RSpec.describe ActivityPub::ProcessAccountService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when unintended value' do
|
||||
let(:searchable_by) { 'ohagi' }
|
||||
|
||||
it 'searchability is direct' do
|
||||
expect(subject.searchability).to eq 'limited'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when default value' do
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue