2017-08-08 22:52:15 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub::Activity::Update < ActivityPub::Activity
|
|
|
|
def perform
|
2020-07-22 12:43:17 +03:00
|
|
|
dereference_object!
|
|
|
|
|
2022-01-19 23:37:27 +02:00
|
|
|
if equals_or_includes_any?(@object['type'], %w(Application Group Organization Person Service))
|
2019-03-12 23:58:59 +02:00
|
|
|
update_account
|
2022-01-19 23:37:27 +02:00
|
|
|
elsif equals_or_includes_any?(@object['type'], %w(Note Question))
|
|
|
|
update_status
|
2022-03-17 01:46:49 +02:00
|
|
|
elsif converted_object_type?
|
|
|
|
Status.find_by(uri: object_uri, account_id: @account.id)
|
2019-03-12 23:58:59 +02:00
|
|
|
end
|
2017-08-08 22:52:15 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_account
|
2022-01-19 23:37:27 +02:00
|
|
|
return reject_payload! if @account.uri != object_uri
|
2018-09-18 17:45:58 +03:00
|
|
|
|
2018-08-26 21:21:03 +03:00
|
|
|
ActivityPub::ProcessAccountService.new.call(@account.username, @account.domain, @object, signed_with_known_key: true)
|
2017-08-08 22:52:15 +03:00
|
|
|
end
|
2019-03-11 01:49:31 +02:00
|
|
|
|
2022-01-19 23:37:27 +02:00
|
|
|
def update_status
|
2022-03-12 10:11:36 +02:00
|
|
|
return reject_payload! if invalid_origin?(object_uri)
|
2019-03-12 23:58:59 +02:00
|
|
|
|
2022-02-26 18:51:59 +02:00
|
|
|
@status = Status.find_by(uri: object_uri, account_id: @account.id)
|
2019-03-11 01:49:31 +02:00
|
|
|
|
2022-02-26 18:51:59 +02:00
|
|
|
return if @status.nil?
|
2022-01-19 23:37:27 +02:00
|
|
|
|
2022-02-26 18:51:59 +02:00
|
|
|
ActivityPub::ProcessStatusUpdateService.new.call(@status, @object)
|
|
|
|
end
|
2017-08-08 22:52:15 +03:00
|
|
|
end
|