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.

32 lines
893 B

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