Add: #595 リモート保留中アカウントからメンションが来た場合にuriを記録し、承認時にフェッチしに行く処理 (#620)

* Add: #591 リモート保留中アカウントからメンションが来た場合にuriを記録し、承認時にフェッチしに行く処理

* Rename fetch_remove_status_worker.rb to fetch_remote_status_worker.rb

* Wip

* Add lock code
This commit is contained in:
KMY(雪あすか) 2024-02-29 12:54:47 +09:00 committed by GitHub
parent b2acc7dbb8
commit 2ab9ea642a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 307 additions and 15 deletions

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class EnableFollowRequestsService < BaseService
class ActivateFollowRequestsService < BaseService
include Payloadable
include FollowHelper

View file

@ -0,0 +1,31 @@
# frozen_string_literal: true
class ActivateRemoteStatusesService < BaseService
include Payloadable
include FollowHelper
def call(account)
@account = account
PendingStatus.transaction do
PendingStatus.where(account: account).find_each do |status_info|
approve_status!(status_info)
end
end
end
private
def approve_status!(pending)
account_id = pending.account_id
fetch_account_id = pending.fetch_account_id
fetch_account = pending.fetch_account
uri = pending.uri
pending.destroy!
return if fetch_account.suspended?
return if ActivityPub::TagManager.instance.uri_to_resource(uri, Status).present?
ActivityPub::FetchRemoteStatusWorker.perform_async(uri, account_id, fetch_account_id)
end
end

View file

@ -56,7 +56,7 @@ class ActivityPub::ProcessCollectionService < BaseService
end
def activity_allowed_while_remote_pending?
%w(Follow).include?(@json['type']) || activity_allowed_while_suspended?
%w(Follow Create).include?(@json['type']) || activity_allowed_while_suspended?
end
def process_items(items)

View file

@ -20,6 +20,7 @@ class DeleteAccountService < BaseService
devices
domain_blocks
featured_tags
fetchable_pending_statuses
follow_requests
list_accounts
migrations
@ -29,6 +30,7 @@ class DeleteAccountService < BaseService
owned_lists
passive_relationships
pending_follow_requests
pending_statuses
report_notes
scheduled_statuses
scheduled_expiration_statuses
@ -51,6 +53,7 @@ class DeleteAccountService < BaseService
devices
domain_blocks
featured_tags
fetchable_pending_statuses
follow_requests
list_accounts
migrations
@ -59,6 +62,7 @@ class DeleteAccountService < BaseService
notifications
owned_lists
pending_follow_requests
pending_statuses
scheduled_statuses
scheduled_expiration_statuses
status_pins