From 7348de7e41c35ca48f786f47dcfd64dee4fb1af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Wed, 4 Dec 2024 08:15:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20=E3=83=95=E3=83=AC=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=90=E3=83=BC=E7=94=B3=E8=AB=8B=E6=99=82?= =?UTF-8?q?=E3=80=81=E3=83=89=E3=83=A1=E3=82=A4=E3=83=B3=E3=82=92=E5=81=BD?= =?UTF-8?q?=E8=A3=85=E3=81=97=E3=81=A6=E7=84=A1=E9=96=A2=E4=BF=82=E3=81=AE?= =?UTF-8?q?Inbox=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E8=84=86=E5=BC=B1=E6=80=A7=20(#934)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/activitypub/activity/follow.rb | 14 ++++-------- app/models/friend_domain.rb | 1 + spec/lib/activitypub/activity/follow_spec.rb | 23 +++++++++++++------- spec/models/friend_domain_spec.rb | 1 - 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb index 75c88d964e..256d72acb9 100644 --- a/app/lib/activitypub/activity/follow.rb +++ b/app/lib/activitypub/activity/follow.rb @@ -60,19 +60,13 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity already_accepted = friend.accepted? friend.update!(passive_state: :pending, active_state: :idle, passive_follow_activity_id: @json['id']) else - @friend = FriendDomain.new(domain: @account.domain, passive_state: :pending, passive_follow_activity_id: @json['id']) - @friend.inbox_url = @json['inboxUrl'].presence || @friend.default_inbox_url - @friend.save! + @friend = FriendDomain.create!(domain: @account.domain, passive_state: :pending, passive_follow_activity_id: @json['id'], inbox_url: @account.preferred_inbox_url) end - if already_accepted || Setting.unlocked_friend - friend.accept! + friend.accept! if already_accepted || Setting.unlocked_friend - # Notify for admin even if unlocked - notify_staff_about_pending_friend_server! unless already_accepted - else - notify_staff_about_pending_friend_server! - end + # Notify for admin + notify_staff_about_pending_friend_server! unless already_accepted end def friend diff --git a/app/models/friend_domain.rb b/app/models/friend_domain.rb index 88ebd9338b..2ca501e21d 100644 --- a/app/models/friend_domain.rb +++ b/app/models/friend_domain.rb @@ -116,6 +116,7 @@ class FriendDomain < ApplicationRecord object: ActivityPub::TagManager::COLLECTIONS[:public], # Cannot use inbox_url method because this model also has inbox_url column + # This is deprecated property. Newer version's kmyblue will ignore it. inboxUrl: "https://#{Rails.configuration.x.web_domain}/inbox", } end diff --git a/spec/lib/activitypub/activity/follow_spec.rb b/spec/lib/activitypub/activity/follow_spec.rb index ec0e5e4eef..12c30feb28 100644 --- a/spec/lib/activitypub/activity/follow_spec.rb +++ b/spec/lib/activitypub/activity/follow_spec.rb @@ -380,11 +380,10 @@ RSpec.describe ActivityPub::Activity::Follow do context 'when given a friend server' do subject { described_class.new(json, sender) } - let(:sender) { Fabricate(:account, domain: 'abc.com', url: 'https://abc.com/#actor') } + let(:sender) { Fabricate(:account, domain: 'abc.com', url: 'https://abc.com/#actor', shared_inbox_url: 'https://abc.com/shared_inbox') } let!(:friend) { Fabricate(:friend_domain, domain: 'abc.com', inbox_url: 'https://example.com/inbox', passive_state: :idle) } let!(:owner_user) { Fabricate(:user, role: UserRole.find_by(name: 'Owner')) } let!(:patch_user) { Fabricate(:user, role: Fabricate(:user_role, name: 'OhagiOps', permissions: UserRole::FLAGS[:manage_federation])) } - let(:inbox_url) { nil } let(:json) do { @@ -393,7 +392,6 @@ RSpec.describe ActivityPub::Activity::Follow do type: 'Follow', actor: ActivityPub::TagManager.instance.uri_for(sender), object: 'https://www.w3.org/ns/activitystreams#Public', - inboxUrl: inbox_url, }.with_indifferent_access end @@ -415,25 +413,34 @@ RSpec.describe ActivityPub::Activity::Follow do expect(friend).to_not be_nil expect(friend.they_are_pending?).to be true expect(friend.passive_follow_activity_id).to eq 'foo' - expect(friend.inbox_url).to eq 'https://abc.com/inbox' + expect(friend.inbox_url).to eq 'https://abc.com/shared_inbox' end end - context 'when no record and inbox_url is specified' do - let(:inbox_url) { 'https://ohagi.com/inbox' } + context 'when old spec which no record and inbox_url is specified' do + let(:json) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: 'foo', + type: 'Follow', + actor: ActivityPub::TagManager.instance.uri_for(sender), + object: 'https://www.w3.org/ns/activitystreams#Public', + inboxUrl: 'https://evil.org/bad_inbox', + }.with_indifferent_access + end before do friend.destroy! end - it 'marks the friend as pending' do + it 'marks the friend as pending but inboxUrl is not working' do subject.perform friend = FriendDomain.find_by(domain: 'abc.com') expect(friend).to_not be_nil expect(friend.they_are_pending?).to be true expect(friend.passive_follow_activity_id).to eq 'foo' - expect(friend.inbox_url).to eq 'https://ohagi.com/inbox' + expect(friend.inbox_url).to eq 'https://abc.com/shared_inbox' end end diff --git a/spec/models/friend_domain_spec.rb b/spec/models/friend_domain_spec.rb index 336f921ebd..d3992ed149 100644 --- a/spec/models/friend_domain_spec.rb +++ b/spec/models/friend_domain_spec.rb @@ -21,7 +21,6 @@ RSpec.describe FriendDomain do type: 'Follow', actor: 'https://cb6e6126.ngrok.io/actor', object: 'https://www.w3.org/ns/activitystreams#Public', - inboxUrl: 'https://cb6e6126.ngrok.io/inbox', }))).to have_been_made.once end end From d1e6027cf63e8eb1d198794c493c19b184fb3e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Wed, 4 Dec 2024 08:16:00 +0900 Subject: [PATCH 2/2] Bump version to 16.0 (#928) --- docker-compose.yml | 6 +++--- lib/mastodon/version.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d7958cedfd..5ed44bd82c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: web: # You can uncomment the following line if you want to not use the prebuilt image, for example if you have local code changes build: . - image: kmyblue:16.0-dev + image: kmyblue:16.0 restart: always env_file: .env.production command: bundle exec puma -C config/puma.rb @@ -83,7 +83,7 @@ services: build: dockerfile: ./streaming/Dockerfile context: . - image: kmyblue-streaming:16.0-dev + image: kmyblue-streaming:16.0 restart: always env_file: .env.production command: node ./streaming/index.js @@ -101,7 +101,7 @@ services: sidekiq: build: . - image: kmyblue:16.0-dev + image: kmyblue:16.0 restart: always env_file: .env.production command: bundle exec sidekiq diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index b57856e472..30f4e62655 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -18,8 +18,8 @@ module Mastodon def kmyblue_flag # 'LTS' - 'dev' - # nil + # 'dev' + nil end def major