update.rb 1.0 KB

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