* Add: #591 リモート保留中アカウントからメンションが来た場合にuriを記録し、承認時にフェッチしに行く処理 * Rename fetch_remove_status_worker.rb to fetch_remote_status_worker.rb * Wip * Add lock code
This commit is contained in:
parent
b2acc7dbb8
commit
2ab9ea642a
22 changed files with 307 additions and 15 deletions
32
app/services/activate_follow_requests_service.rb
Normal file
32
app/services/activate_follow_requests_service.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivateFollowRequestsService < 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
|
Loading…
Add table
Add a link
Reference in a new issue