Add: #586 保留中のリモートアカウントからのフォローが飛んできた場合に記録する (#590)

* Add: #586 保留中のリモートアカウントからのフォローが飛んできた場合に記録する

* 本家に戻す処理を修正

* Fix test

* Fix worker link

* Fix test

* リモートアカウント拒否時に既存のリクエストを削除
This commit is contained in:
KMY(雪あすか) 2024-02-18 10:48:48 +09:00 committed by GitHub
parent 1b3c0e3fb7
commit dfc9f35d71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 262 additions and 31 deletions

View file

@ -48,13 +48,17 @@ class ActivityPub::ProcessCollectionService < BaseService
end
def suspended_actor?
@account.suspended? && !activity_allowed_while_suspended?
@account.suspended? && (@account.remote_pending ? !activity_allowed_while_remote_pending? : !activity_allowed_while_suspended?)
end
def activity_allowed_while_suspended?
%w(Delete Reject Undo Update).include?(@json['type'])
end
def activity_allowed_while_remote_pending?
%w(Follow).include?(@json['type']) || activity_allowed_while_suspended?
end
def process_items(items)
items.reverse_each.filter_map { |item| process_item(item) }
end

View file

@ -28,6 +28,7 @@ class DeleteAccountService < BaseService
notifications
owned_lists
passive_relationships
pending_follow_requests
report_notes
scheduled_statuses
scheduled_expiration_statuses
@ -57,6 +58,7 @@ class DeleteAccountService < BaseService
muted_by_relationships
notifications
owned_lists
pending_follow_requests
scheduled_statuses
scheduled_expiration_statuses
status_pins

View file

@ -0,0 +1,32 @@
# frozen_string_literal: true
class EnableFollowRequestsService < BaseService
include Payloadable
include FollowHelper
def call(account)
@account = account
PendingFollowRequest.transaction do
PendingFollowRequest.where(account: account).find_each do |follow_request|
approve_follow!(follow_request)
end
end
end
private
def approve_follow!(pending)
follow_request = FollowRequest.create!(account: @account, target_account: pending.target_account, uri: pending.uri)
pending.destroy!
target_account = follow_request.target_account
if request_pending_follow?(@account, target_account)
LocalNotificationWorker.perform_async(target_account.id, follow_request.id, 'FollowRequest', 'follow_request')
else
AuthorizeFollowService.new.call(@account, target_account)
LocalNotificationWorker.perform_async(target_account.id, ::Follow.find_by(account: @account, target_account: target_account).id, 'Follow', 'follow')
end
end
end