|
|
|
@ -18,10 +18,11 @@ class ActivityPub::ProcessAccountService < BaseService |
|
|
|
|
|
|
|
|
|
RedisLock.acquire(lock_options) do |lock| |
|
|
|
|
if lock.acquired? |
|
|
|
|
@account = Account.remote.find_by(uri: @uri) if @options[:only_key] |
|
|
|
|
@account ||= Account.find_remote(@username, @domain) |
|
|
|
|
@old_public_key = @account&.public_key |
|
|
|
|
@old_protocol = @account&.protocol |
|
|
|
|
@account = Account.remote.find_by(uri: @uri) if @options[:only_key] |
|
|
|
|
@account ||= Account.find_remote(@username, @domain) |
|
|
|
|
@old_public_key = @account&.public_key |
|
|
|
|
@old_protocol = @account&.protocol |
|
|
|
|
@suspension_changed = false |
|
|
|
|
|
|
|
|
|
create_account if @account.nil? |
|
|
|
|
update_account |
|
|
|
@ -37,8 +38,9 @@ class ActivityPub::ProcessAccountService < BaseService |
|
|
|
|
after_protocol_change! if protocol_changed? |
|
|
|
|
after_key_change! if key_changed? && !@options[:signed_with_known_key] |
|
|
|
|
clear_tombstones! if key_changed? |
|
|
|
|
after_suspension_change! if suspension_changed? |
|
|
|
|
|
|
|
|
|
unless @options[:only_key] |
|
|
|
|
unless @options[:only_key] || @account.suspended? |
|
|
|
|
check_featured_collection! if @account.featured_collection_url.present? |
|
|
|
|
check_links! unless @account.fields.empty? |
|
|
|
|
end |
|
|
|
@ -52,20 +54,23 @@ class ActivityPub::ProcessAccountService < BaseService |
|
|
|
|
|
|
|
|
|
def create_account |
|
|
|
|
@account = Account.new |
|
|
|
|
@account.protocol = :activitypub |
|
|
|
|
@account.username = @username |
|
|
|
|
@account.domain = @domain |
|
|
|
|
@account.private_key = nil |
|
|
|
|
@account.suspended_at = domain_block.created_at if auto_suspend? |
|
|
|
|
@account.silenced_at = domain_block.created_at if auto_silence? |
|
|
|
|
@account.protocol = :activitypub |
|
|
|
|
@account.username = @username |
|
|
|
|
@account.domain = @domain |
|
|
|
|
@account.private_key = nil |
|
|
|
|
@account.suspended_at = domain_block.created_at if auto_suspend? |
|
|
|
|
@account.suspension_origin = :local if auto_suspend? |
|
|
|
|
@account.silenced_at = domain_block.created_at if auto_silence? |
|
|
|
|
@account.save |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def update_account |
|
|
|
|
@account.last_webfingered_at = Time.now.utc unless @options[:only_key] |
|
|
|
|
@account.protocol = :activitypub |
|
|
|
|
|
|
|
|
|
set_immediate_attributes! |
|
|
|
|
set_fetchable_attributes! unless @options[:only_keys] |
|
|
|
|
set_suspension! |
|
|
|
|
set_immediate_attributes! unless @account.suspended? |
|
|
|
|
set_fetchable_attributes! unless @options[:only_keys] || @account.suspended? |
|
|
|
|
|
|
|
|
|
@account.save_with_optional_media! |
|
|
|
|
end |
|
|
|
@ -99,6 +104,18 @@ class ActivityPub::ProcessAccountService < BaseService |
|
|
|
|
@account.moved_to_account = @json['movedTo'].present? ? moved_account : nil |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def set_suspension! |
|
|
|
|
return if @account.suspended? && @account.suspension_origin_local? |
|
|
|
|
|
|
|
|
|
if @account.suspended? && !@json['suspended'] |
|
|
|
|
@account.unsuspend! |
|
|
|
|
@suspension_changed = true |
|
|
|
|
elsif !@account.suspended? && @json['suspended'] |
|
|
|
|
@account.suspend!(origin: :remote) |
|
|
|
|
@suspension_changed = true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def after_protocol_change! |
|
|
|
|
ActivityPub::PostUpgradeWorker.perform_async(@account.domain) |
|
|
|
|
end |
|
|
|
@ -107,6 +124,14 @@ class ActivityPub::ProcessAccountService < BaseService |
|
|
|
|
RefollowWorker.perform_async(@account.id) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def after_suspension_change! |
|
|
|
|
if @account.suspended? |
|
|
|
|
Admin::SuspensionWorker.perform_async(@account.id) |
|
|
|
|
else |
|
|
|
|
Admin::UnsuspensionWorker.perform_async(@account.id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def check_featured_collection! |
|
|
|
|
ActivityPub::SynchronizeFeaturedCollectionWorker.perform_async(@account.id) |
|
|
|
|
end |
|
|
|
@ -227,6 +252,10 @@ class ActivityPub::ProcessAccountService < BaseService |
|
|
|
|
!@old_public_key.nil? && @old_public_key != @account.public_key |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def suspension_changed? |
|
|
|
|
@suspension_changed |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def clear_tombstones! |
|
|
|
|
Tombstone.where(account_id: @account.id).delete_all |
|
|
|
|
end |
|
|
|
|