logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

account_controller_concern.rb (1157B)


  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. actor_url_link,
  21. ]
  22. )
  23. end
  24. def webfinger_account_link
  25. [
  26. webfinger_account_url,
  27. [%w(rel lrdd), %w(type application/xrd+xml)],
  28. ]
  29. end
  30. def atom_account_url_link
  31. [
  32. account_url(@account, format: 'atom'),
  33. [%w(rel alternate), %w(type application/atom+xml)],
  34. ]
  35. end
  36. def actor_url_link
  37. [
  38. ActivityPub::TagManager.instance.uri_for(@account),
  39. [%w(rel alternate), %w(type application/activity+json)],
  40. ]
  41. end
  42. def webfinger_account_url
  43. webfinger_url(resource: @account.to_webfinger_s)
  44. end
  45. def check_account_suspension
  46. gone if @account.suspended?
  47. end
  48. end