Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. | 1 | # frozen_string_literal: true
  2. | 2 |
  3. | 3 | class ActivityPub::InboxesController < Api::BaseController
  4. | 4 | include SignatureVerification
  5. | 5 |
  6. | 6 | before_action :set_account
  7. | 7 |
  8. | 8 | def create
  9. 18 (15.3%) | 9 | if signed_request_account
  10. 1 (0.8%) | 10 | upgrade_account
  11. 9 (7.6%) | 11 | process_payload
  12. 2 (1.7%) | 12 | head 201
  13. | 13 | else
  14. | 14 | head 202
  15. | 15 | end
  16. | 16 | end
  17. | 17 |
  18. | 18 | private
  19. | 19 |
  20. | 20 | def set_account
  21. 31 (26.3%) | 21 | @account = Account.find_local!(params[:account_username]) if params[:account_username]
  22. | 22 | end
  23. | 23 |
  24. | 24 | def body
  25. | 25 | @body ||= request.body.read
  26. | 26 | end
  27. | 27 |
  28. | 28 | def upgrade_account
  29. 1 (0.8%) | 29 | if signed_request_account.ostatus?
  30. | 30 | signed_request_account.update(last_webfingered_at: nil)
  31. | 31 | ResolveRemoteAccountWorker.perform_async(signed_request_account.acct)
  32. | 32 | end
  33. | 33 |
  34. | 34 | Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id) if signed_request_account.subscribed?
  35. | 35 | end
  36. | 36 |
  37. | 37 | def process_payload
  38. 9 (7.6%) | 38 | ActivityPub::ProcessingWorker.perform_async(signed_request_account.id, body.force_encoding('UTF-8'))
  39. | 39 | end
  40. | 40 | end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement