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.

28 lines
877 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. update_account if equals_or_includes_any?(@object['type'], SUPPORTED_TYPES)
  6. update_poll if equals_or_includes_any?(@object['type'], %w(Question))
  7. end
  8. private
  9. def update_account
  10. return if @account.uri != object_uri
  11. ActivityPub::ProcessAccountService.new.call(@account.username, @account.domain, @object, signed_with_known_key: true)
  12. end
  13. def update_poll
  14. return reject_payload! if invalid_origin?(@object['id'])
  15. status = Status.find_by(uri: object_uri, account_id: @account.id)
  16. return if status.nil? || status.poll_id.nil?
  17. poll = Poll.find(status.poll_id)
  18. return if poll.nil?
  19. ActivityPub::ProcessPollService.new.call(poll, @object)
  20. end
  21. end