commit
3c851f2d21
7 changed files with 40 additions and 14 deletions
|
@ -507,15 +507,15 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
|
||||
def searchability_from_audience
|
||||
if audience_searchable_by.nil?
|
||||
nil
|
||||
elsif audience_searchable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) }
|
||||
return nil if audience_searchable_by.blank?
|
||||
|
||||
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?(@account.followers_url)
|
||||
:private
|
||||
else
|
||||
elsif audience_searchable_by.include?(@account.uri) || audience_searchable_by.include?(@account.url)
|
||||
:direct
|
||||
end
|
||||
end
|
||||
|
|
|
@ -237,12 +237,10 @@ class ActivityPub::TagManager
|
|||
[COLLECTIONS[:public]]
|
||||
when 'private'
|
||||
[account_followers_url(status.account)]
|
||||
when 'direct'
|
||||
status.conversation_id.present? ? [uri_for(status.conversation)] : []
|
||||
when 'limited'
|
||||
['as:Limited', 'kmyblue:Limited']
|
||||
else
|
||||
[]
|
||||
status.conversation_id.present? ? [uri_for(status.conversation), account_url(status.account)] : [account_url(status.account)]
|
||||
end
|
||||
|
||||
searchable_by.concat(mentions_uris(status)).compact
|
||||
|
@ -257,7 +255,7 @@ class ActivityPub::TagManager
|
|||
when 'limited'
|
||||
['as:Limited', 'kmyblue:Limited']
|
||||
else
|
||||
[]
|
||||
[account_url(account)]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
end
|
||||
|
||||
def searchability_from_audience
|
||||
if audience_searchable_by.nil?
|
||||
if audience_searchable_by.blank?
|
||||
bio = searchability_from_bio
|
||||
return bio unless bio.nil?
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Mastodon
|
|||
end
|
||||
|
||||
def kmyblue_minor
|
||||
23
|
||||
24
|
||||
end
|
||||
|
||||
def kmyblue_flag
|
||||
|
|
|
@ -564,7 +564,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
|
||||
context 'with direct' do
|
||||
let(:searchable_by) { '' }
|
||||
let(:searchable_by) { 'https://example.com/actor' }
|
||||
|
||||
it 'create status' do
|
||||
status = sender.statuses.first
|
||||
|
@ -574,6 +574,17 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with empty array' do
|
||||
let(:searchable_by) { '' }
|
||||
|
||||
it 'create status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.searchability).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with direct when not specify' do
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ require 'rails_helper'
|
|||
describe ActivityPub::NoteSerializer do
|
||||
subject { JSON.parse(@serialization.to_json) }
|
||||
|
||||
let!(:account) { Fabricate(:account) }
|
||||
let!(:account) { Fabricate(:account, searchability: :public) }
|
||||
let!(:other) { Fabricate(:account) }
|
||||
let!(:parent) { Fabricate(:status, account: account, visibility: :public, language: 'zh-TW') }
|
||||
let!(:parent) { Fabricate(:status, account: account, visibility: :public, searchability: searchability, language: 'zh-TW') }
|
||||
let!(:reply_by_account_first) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
||||
let!(:reply_by_account_next) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
|
||||
let!(:reply_by_other_first) { Fabricate(:status, account: other, thread: parent, visibility: :public) }
|
||||
|
@ -16,6 +16,7 @@ describe ActivityPub::NoteSerializer do
|
|||
let!(:referred) { nil }
|
||||
let!(:referred2) { nil }
|
||||
let(:convert_to_quote) { false }
|
||||
let(:searchability) { :public }
|
||||
|
||||
before(:each) do
|
||||
parent.references << referred if referred.present?
|
||||
|
@ -55,6 +56,14 @@ describe ActivityPub::NoteSerializer do
|
|||
expect(subject['replies']['first']['items']).to_not include(reply_by_account_visibility_direct.uri)
|
||||
end
|
||||
|
||||
context 'when direct searchability' do
|
||||
let(:searchability) { :direct }
|
||||
|
||||
it 'send as direct searchability' do
|
||||
expect(subject['searchableBy']).to include "https://cb6e6126.ngrok.io/users/#{account.username}"
|
||||
end
|
||||
end
|
||||
|
||||
context 'when has quote but no_convert setting' do
|
||||
let(:referred) { Fabricate(:status) }
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
end
|
||||
|
||||
context 'when direct' do
|
||||
let(:searchable_by) { '' }
|
||||
let(:searchable_by) { 'https://foo.test' }
|
||||
|
||||
it 'searchability is direct' do
|
||||
expect(subject.searchability).to eq 'direct'
|
||||
|
@ -72,6 +72,14 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when empty array' do
|
||||
let(:searchable_by) { '' }
|
||||
|
||||
it 'searchability is direct' do
|
||||
expect(subject.searchability).to eq 'direct'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when default value' do
|
||||
let(:searchable_by) { nil }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue