account_controller_concern.rb 848 B

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