Skip to content

Commit

Permalink
フレンド自動承認設定を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 10, 2023
1 parent fece007 commit 7f4034e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 28 deletions.
6 changes: 4 additions & 2 deletions app/lib/activitypub/activity/follow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/friend_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/friend_servers/_friend_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions spec/lib/activitypub/activity/follow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f4034e

Please sign in to comment.