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.

40 lines
967 B

  1. class AccountsController < ApplicationController
  2. layout 'public'
  3. before_action :set_account
  4. before_action :set_webfinger_header
  5. before_action :authenticate_user!, only: [:follow, :unfollow]
  6. def show
  7. @statuses = @account.statuses.order('id desc').includes(thread: [:account], reblog: [:account], stream_entry: [])
  8. respond_to do |format|
  9. format.html
  10. format.atom
  11. end
  12. end
  13. def follow
  14. current_user.account.follow!(@account)
  15. redirect_to root_path
  16. end
  17. def unfollow
  18. current_user.account.unfollow!(@account)
  19. redirect_to root_path
  20. end
  21. private
  22. def set_account
  23. @account = Account.find_by!(username: params[:username], domain: nil)
  24. end
  25. def set_webfinger_header
  26. response.headers['Link'] = "<#{webfinger_account_url}>; rel=\"lrdd\"; type=\"application/xrd+xml\""
  27. end
  28. def webfinger_account_url
  29. webfinger_url(resource: "acct:#{@account.acct}@#{Rails.configuration.x.local_domain}")
  30. end
  31. end