|
|
@ -24,6 +24,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|
|
|
create_account if @account.nil?
|
|
|
|
create_account if @account.nil?
|
|
|
|
update_account
|
|
|
|
update_account
|
|
|
|
process_tags
|
|
|
|
process_tags
|
|
|
|
|
|
|
|
process_attachments
|
|
|
|
else
|
|
|
|
else
|
|
|
|
raise Mastodon::RaceConditionError
|
|
|
|
raise Mastodon::RaceConditionError
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -151,7 +152,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|
|
|
|
|
|
|
|
|
|
|
def property_values
|
|
|
|
def property_values
|
|
|
|
return unless @json['attachment'].is_a?(Array)
|
|
|
|
return unless @json['attachment'].is_a?(Array)
|
|
|
|
@json['attachment'].select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') }
|
|
|
|
as_array(@json['attachment']).select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def mismatching_origin?(url)
|
|
|
|
def mismatching_origin?(url)
|
|
|
@ -231,6 +232,23 @@ class ActivityPub::ProcessAccountService < BaseService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_attachments
|
|
|
|
|
|
|
|
return if @json['attachment'].blank?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
previous_proofs = @account.identity_proofs.to_a
|
|
|
|
|
|
|
|
current_proofs = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
as_array(@json['attachment']).each do |attachment|
|
|
|
|
|
|
|
|
next unless equals_or_includes?(attachment['type'], 'IdentityProof')
|
|
|
|
|
|
|
|
current_proofs << process_identity_proof(attachment)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
previous_proofs.each do |previous_proof|
|
|
|
|
|
|
|
|
next if current_proofs.any? { |current_proof| current_proof.id == previous_proof.id }
|
|
|
|
|
|
|
|
previous_proof.delete
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def process_emoji(tag)
|
|
|
|
def process_emoji(tag)
|
|
|
|
return if skip_download?
|
|
|
|
return if skip_download?
|
|
|
|
return if tag['name'].blank? || tag['icon'].blank? || tag['icon']['url'].blank?
|
|
|
|
return if tag['name'].blank? || tag['icon'].blank? || tag['icon']['url'].blank?
|
|
|
@ -247,4 +265,12 @@ class ActivityPub::ProcessAccountService < BaseService
|
|
|
|
emoji.image_remote_url = image_url
|
|
|
|
emoji.image_remote_url = image_url
|
|
|
|
emoji.save
|
|
|
|
emoji.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_identity_proof(attachment)
|
|
|
|
|
|
|
|
provider = attachment['signatureAlgorithm']
|
|
|
|
|
|
|
|
provider_username = attachment['name']
|
|
|
|
|
|
|
|
token = attachment['signatureValue']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@account.identity_proofs.where(provider: provider, provider_username: provider_username).find_or_create_by(provider: provider, provider_username: provider_username, token: token)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|