* 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
|
@ -50,6 +50,11 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
def create_status
|
||||
return reject_payload! if unsupported_object_type? || non_matching_uri_hosts?(@account.uri, object_uri) || tombstone_exists? || !related_to_local_activity?
|
||||
|
||||
if @account.suspended?
|
||||
process_pending_status if @account.remote_pending?
|
||||
return
|
||||
end
|
||||
|
||||
with_redis_lock("create:#{object_uri}") do
|
||||
return if delete_arrived_first?(object_uri) || poll_vote?
|
||||
|
||||
|
@ -405,6 +410,20 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, replied_to_status.id) unless replied_to_status.preloadable_poll.hide_totals?
|
||||
end
|
||||
|
||||
def process_pending_status
|
||||
with_redis_lock("pending_status:#{@object['id']}") do
|
||||
return if PendingStatus.exists?(uri: @object['id'])
|
||||
|
||||
fetch_account = as_array(@object['tag'])
|
||||
.filter_map { |tag| equals_or_includes?(tag['type'], 'Mention') && tag['href'] && ActivityPub::TagManager.instance.local_uri?(tag['href']) && ActivityPub::TagManager.instance.uri_to_resource(tag['href'], Account) }
|
||||
.first
|
||||
fetch_account ||= (audience_to + audience_cc).filter_map { |uri| ActivityPub::TagManager.instance.local_uri?(uri) && ActivityPub::TagManager.instance.uri_to_resource(uri, Account) }.first
|
||||
fetch_account ||= Account.representative
|
||||
|
||||
PendingStatus.create!(account: @account, uri: @object['id'], fetch_account: fetch_account)
|
||||
end
|
||||
end
|
||||
|
||||
def resolve_thread(status)
|
||||
return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri)
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
|||
return
|
||||
end
|
||||
|
||||
if @account.suspended?
|
||||
PendingFollowRequest.create!(account: @account, target_account: target_account, uri: @json['id']) if @account.remote_pending?
|
||||
return
|
||||
end
|
||||
|
||||
if target_account.blocking?(@account) || target_account.domain_blocking?(@account.domain) || target_account.moved? || target_account.instance_actor? || block_new_follow?
|
||||
reject_follow_request!(target_account)
|
||||
return
|
||||
|
@ -33,13 +38,6 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
|||
return
|
||||
end
|
||||
|
||||
if @account.suspended? && @account.remote_pending?
|
||||
PendingFollowRequest.create!(account: @account, target_account: target_account, uri: @json['id'])
|
||||
return
|
||||
elsif @account.suspended?
|
||||
return
|
||||
end
|
||||
|
||||
follow_request = FollowRequest.create!(account: @account, target_account: target_account, uri: @json['id'])
|
||||
|
||||
if request_pending_follow?(@account, target_account)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue