The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

42 lines
1.1 KiB

  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 202
  10. else
  11. render plain: signature_verification_failure_reason, status: 401
  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. ResolveAccountWorker.perform_async(signed_request_account.acct)
  25. end
  26. Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id) if signed_request_account.subscribed?
  27. DeliveryFailureTracker.track_inverse_success!(signed_request_account)
  28. end
  29. def process_payload
  30. ActivityPub::ProcessingWorker.perform_async(signed_request_account.id, body.force_encoding('UTF-8'), @account&.id)
  31. end
  32. end