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.

40 lines
938 B

  1. # frozen_string_literal: true
  2. class ActivityPub::InboxesController < Api::BaseController
  3. include SignatureVerification
  4. before_action :set_account
  5. def create
  6. if signed_request_account
  7. upgrade_account
  8. process_payload
  9. head 201
  10. else
  11. head 202
  12. end
  13. end
  14. private
  15. def set_account
  16. @account = Account.find_local!(params[:account_username]) if params[:account_username]
  17. end
  18. def body
  19. @body ||= request.body.read
  20. end
  21. def upgrade_account
  22. if signed_request_account.ostatus?
  23. signed_request_account.update(last_webfingered_at: nil)
  24. ResolveRemoteAccountWorker.perform_async(signed_request_account.acct)
  25. end
  26. Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id) if signed_request_account.subscribed?
  27. end
  28. def process_payload
  29. ActivityPub::ProcessingWorker.perform_async(signed_request_account.id, body.force_encoding('UTF-8'))
  30. end
  31. end