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