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.

51 lines
972 B

  1. # frozen_string_literal: true
  2. module AccountControllerConcern
  3. extend ActiveSupport::Concern
  4. FOLLOW_PER_PAGE = 12
  5. included do
  6. layout 'public'
  7. before_action :set_account
  8. before_action :set_link_headers
  9. before_action :check_account_suspension
  10. end
  11. private
  12. def set_account
  13. @account = Account.find_local!(params[:account_username])
  14. end
  15. def set_link_headers
  16. response.headers['Link'] = LinkHeader.new(
  17. [
  18. webfinger_account_link,
  19. atom_account_url_link,
  20. ]
  21. )
  22. end
  23. def webfinger_account_link
  24. [
  25. webfinger_account_url,
  26. [%w(rel lrdd), %w(type application/xrd+xml)],
  27. ]
  28. end
  29. def atom_account_url_link
  30. [
  31. account_url(@account, format: 'atom'),
  32. [%w(rel alternate), %w(type application/atom+xml)],
  33. ]
  34. end
  35. def webfinger_account_url
  36. webfinger_url(resource: @account.to_webfinger_s)
  37. end
  38. def check_account_suspension
  39. gone if @account.suspended?
  40. end
  41. end