From 7f4034e6e7fe75eaf6b44e325c4c236821bd4480 Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 10 Oct 2023 19:32:14 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=83=AC=E3=83=B3=E3=83=89=E8=87=AA?= =?UTF-8?q?=E5=8B=95=E6=89=BF=E8=AA=8D=E8=A8=AD=E5=AE=9A=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/activitypub/activity/follow.rb | 6 ++++-- app/models/friend_domain.rb | 2 +- .../friend_servers/_friend_fields.html.haml | 3 --- ...15_add_delivery_local_to_friend_domains.rb | 10 +++++++++- db/schema.rb | 1 - spec/lib/activitypub/activity/follow_spec.rb | 20 ------------------- 6 files changed, 14 insertions(+), 28 deletions(-) diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb index 985356a7cb3ca5..e317e53da582ea 100644 --- a/app/lib/activitypub/activity/follow.rb +++ b/app/lib/activitypub/activity/follow.rb @@ -55,10 +55,12 @@ def request_follow_for_friend @friend = FriendDomain.create!(domain: @account.domain, passive_state: :pending, passive_follow_activity_id: @json['id']) end - if already_accepted || friend.unlocked || Setting.unlocked_friend + if already_accepted || Setting.unlocked_friend friend.accept! - else + # Notify for admin even if unlocked + notify_staff_about_pending_friend_server! unless already_accepted + else notify_staff_about_pending_friend_server! end end diff --git a/app/models/friend_domain.rb b/app/models/friend_domain.rb index e919a9132e0b84..70738097a8afd5 100644 --- a/app/models/friend_domain.rb +++ b/app/models/friend_domain.rb @@ -13,10 +13,10 @@ # passive_follow_activity_id :string # available :boolean default(TRUE), not null # pseudo_relay :boolean default(FALSE), not null -# unlocked :boolean default(FALSE), not null # allow_all_posts :boolean default(TRUE), not null # created_at :datetime not null # updated_at :datetime not null +# delivery_local :boolean default(TRUE), not null # class FriendDomain < ApplicationRecord diff --git a/app/views/admin/friend_servers/_friend_fields.html.haml b/app/views/admin/friend_servers/_friend_fields.html.haml index 550e0235be3da7..ad9b0d60caaf88 100644 --- a/app/views/admin/friend_servers/_friend_fields.html.haml +++ b/app/views/admin/friend_servers/_friend_fields.html.haml @@ -16,8 +16,5 @@ .fields-group = f.input :pseudo_relay, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.pseudo_relay'), hint: t('admin.friend_servers.edit.pseudo_relay_hint') -.fields-group - = f.input :unlocked, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.unlocked') - .fields-group = f.input :allow_all_posts, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.allow_all_posts'), hint: t('admin.friend_servers.edit.allow_all_posts_hint') diff --git a/db/migrate/20231009235215_add_delivery_local_to_friend_domains.rb b/db/migrate/20231009235215_add_delivery_local_to_friend_domains.rb index 6409351dd11a37..a42b0166633761 100644 --- a/db/migrate/20231009235215_add_delivery_local_to_friend_domains.rb +++ b/db/migrate/20231009235215_add_delivery_local_to_friend_domains.rb @@ -7,9 +7,17 @@ class AddDeliveryLocalToFriendDomains < ActiveRecord::Migration[7.0] disable_ddl_transaction! - def change + def up safety_assured do add_column_with_default :friend_domains, :delivery_local, :boolean, default: true, allow_null: false + remove_column :friend_domains, :unlocked + end + end + + def down + safety_assured do + remove_column :friend_domains, :delivery_local + add_column_with_default :friend_domains, :unlocked, :boolean, default: false, allow_null: false end end end diff --git a/db/schema.rb b/db/schema.rb index 004a4ba3a0d38a..7a4ee11608c751 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -686,7 +686,6 @@ t.string "passive_follow_activity_id" t.boolean "available", default: true, null: false t.boolean "pseudo_relay", default: false, null: false - t.boolean "unlocked", default: false, null: false t.boolean "allow_all_posts", default: true, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false diff --git a/spec/lib/activitypub/activity/follow_spec.rb b/spec/lib/activitypub/activity/follow_spec.rb index 74b024253174e1..64ce3511779f8f 100644 --- a/spec/lib/activitypub/activity/follow_spec.rb +++ b/spec/lib/activitypub/activity/follow_spec.rb @@ -402,26 +402,6 @@ end end - context 'when unlocked' do - before do - friend.update(unlocked: true) - stub_request(:post, 'https://example.com/inbox') - end - - it 'marks the friend as accepted' do - subject.perform - - friend = FriendDomain.find_by(domain: 'abc.com') - expect(friend).to_not be_nil - expect(friend.they_are_accepted?).to be true - expect(a_request(:post, 'https://example.com/inbox').with(body: hash_including({ - id: 'foo#accepts/friends', - type: 'Accept', - object: 'foo', - }))).to have_been_made.once - end - end - context 'when unlocked on admin settings' do before do Form::AdminSettings.new(unlocked_friend: '1').save