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