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