From ec9644b9a67ce78514fb12336063cec870476929 Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 10 Sep 2024 06:56:10 +0900 Subject: [PATCH 1/2] Bump version to 5.24 LTS --- lib/mastodon/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 92b18006f5050e..aa7c293c9b176f 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -9,7 +9,7 @@ def kmyblue_major end def kmyblue_minor - 23 + 24 end def kmyblue_flag From b6278e0d395d8aea7cb9275207fadebd500ae103 Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 10 Sep 2024 06:51:26 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20LD=20Signatures=E3=81=A7=E7=BD=B2?= =?UTF-8?q?=E5=90=8D=E3=81=95=E3=82=8C=E3=81=9F=E6=8A=95=E7=A8=BF=E3=81=AE?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E8=A8=B1=E5=8F=AF=EF=BC=88=E6=A4=9C=E7=B4=A2?= =?UTF-8?q?=E7=AF=84=E5=9B=B2=EF=BC=89=E3=81=8C=E6=94=B9=E7=AB=84=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/activitypub/activity/create.rb | 8 ++++---- app/lib/activitypub/tag_manager.rb | 6 ++---- app/services/activitypub/process_account_service.rb | 2 +- spec/lib/activitypub/activity/create_spec.rb | 13 ++++++++++++- .../serializers/activitypub/note_serializer_spec.rb | 13 +++++++++++-- .../activitypub/process_account_service_spec.rb | 10 +++++++++- 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 56a3f7186bbb1a..7a80133165c38e 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -507,15 +507,15 @@ def join_group! 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 diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 52f7ed32ab4b4c..b8a969c55899ea 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -237,12 +237,10 @@ def searchable_by(status) [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 @@ def account_searchable_by(account) when 'limited' ['as:Limited', 'kmyblue:Limited'] else - [] + [account_url(account)] end end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 5d98bb617d518f..bf276aa33ce0e3 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -267,7 +267,7 @@ def audience_searchable_by end def searchability_from_audience - if audience_searchable_by.nil? + if audience_searchable_by.blank? bio = searchability_from_bio return bio unless bio.nil? diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index b6fa8da6b0b468..4dad74c4bc5bdd 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -564,7 +564,7 @@ def activity_for_object(json) 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 @@ def activity_for_object(json) 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 } diff --git a/spec/serializers/activitypub/note_serializer_spec.rb b/spec/serializers/activitypub/note_serializer_spec.rb index 280f6e37bec063..9a82d652984f23 100644 --- a/spec/serializers/activitypub/note_serializer_spec.rb +++ b/spec/serializers/activitypub/note_serializer_spec.rb @@ -5,9 +5,9 @@ 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 @@ 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 @@ 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) } diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index f782c69cdb9d8e..05067b23414dea 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -49,7 +49,7 @@ 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 @@ 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 }