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.

64 lines
1.3 KiB

  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_instance_presenter
  9. before_action :set_link_headers
  10. before_action :check_account_suspension
  11. end
  12. private
  13. def set_account
  14. @account = Account.find_local!(params[:account_username])
  15. end
  16. def set_instance_presenter
  17. @instance_presenter = InstancePresenter.new
  18. end
  19. def set_link_headers
  20. response.headers['Link'] = LinkHeader.new(
  21. [
  22. webfinger_account_link,
  23. atom_account_url_link,
  24. actor_url_link,
  25. ]
  26. )
  27. end
  28. def webfinger_account_link
  29. [
  30. webfinger_account_url,
  31. [%w(rel lrdd), %w(type application/xrd+xml)],
  32. ]
  33. end
  34. def atom_account_url_link
  35. [
  36. account_url(@account, format: 'atom'),
  37. [%w(rel alternate), %w(type application/atom+xml)],
  38. ]
  39. end
  40. def actor_url_link
  41. [
  42. ActivityPub::TagManager.instance.uri_for(@account),
  43. [%w(rel alternate), %w(type application/activity+json)],
  44. ]
  45. end
  46. def webfinger_account_url
  47. webfinger_url(resource: @account.to_webfinger_s)
  48. end
  49. def check_account_suspension
  50. gone if @account.suspended?
  51. end
  52. end