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.

49 lines
962 B

  1. # frozen_string_literal: true
  2. module AccountControllerConcern
  3. extend ActiveSupport::Concern
  4. include AccountOwnedConcern
  5. FOLLOW_PER_PAGE = 12
  6. included do
  7. layout 'public'
  8. before_action :set_instance_presenter
  9. before_action :set_link_headers, if: -> { request.format.nil? || request.format == :html }
  10. end
  11. private
  12. def set_instance_presenter
  13. @instance_presenter = InstancePresenter.new
  14. end
  15. def set_link_headers
  16. response.headers['Link'] = LinkHeader.new(
  17. [
  18. webfinger_account_link,
  19. actor_url_link,
  20. ]
  21. )
  22. end
  23. def webfinger_account_link
  24. [
  25. webfinger_account_url,
  26. [%w(rel lrdd), %w(type application/jrd+json)],
  27. ]
  28. end
  29. def actor_url_link
  30. [
  31. ActivityPub::TagManager.instance.uri_for(@account),
  32. [%w(rel alternate), %w(type application/activity+json)],
  33. ]
  34. end
  35. def webfinger_account_url
  36. webfinger_url(resource: @account.to_webfinger_s)
  37. end
  38. end