You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
930 B

  1. # frozen_string_literal: true
  2. class ActivityPub::Activity::Update < ActivityPub::Activity
  3. def perform
  4. dereference_object!
  5. if equals_or_includes_any?(@object['type'], %w(Application Group Organization Person Service))
  6. update_account
  7. elsif equals_or_includes_any?(@object['type'], %w(Note Question))
  8. update_status
  9. elsif converted_object_type?
  10. Status.find_by(uri: object_uri, account_id: @account.id)
  11. end
  12. end
  13. private
  14. def update_account
  15. return reject_payload! if @account.uri != object_uri
  16. ActivityPub::ProcessAccountService.new.call(@account.username, @account.domain, @object, signed_with_known_key: true)
  17. end
  18. def update_status
  19. return reject_payload! if invalid_origin?(object_uri)
  20. @status = Status.find_by(uri: object_uri, account_id: @account.id)
  21. return if @status.nil?
  22. ActivityPub::ProcessStatusUpdateService.new.call(@status, @object)
  23. end
  24. end