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.

53 lines
1.5 KiB

  1. class AccountsController < ApplicationController
  2. layout 'public'
  3. before_action :set_account
  4. before_action :set_link_headers
  5. def show
  6. respond_to do |format|
  7. format.html do
  8. @statuses = @account.statuses.order('id desc').with_includes.with_counters.paginate(page: params[:page], per_page: 10)
  9. end
  10. format.atom do
  11. @entries = @account.stream_entries.order('id desc').with_includes.paginate_by_max_id(20, params[:max_id] || nil)
  12. end
  13. end
  14. end
  15. def follow
  16. FollowService.new.call(current_user.account, @account.acct)
  17. redirect_to account_path(@account)
  18. end
  19. def unfollow
  20. UnfollowService.new.call(current_user.account, @account)
  21. redirect_to account_path(@account)
  22. end
  23. def followers
  24. @followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 6)
  25. end
  26. def following
  27. @following = @account.following.order('follows.created_at desc').paginate(page: params[:page], per_page: 6)
  28. end
  29. private
  30. def set_account
  31. @account = Account.find_local!(params[:username])
  32. end
  33. def set_link_headers
  34. response.headers['Link'] = LinkHeader.new([
  35. [webfinger_account_url, [['rel', 'lrdd'], ['type', 'application/xrd+xml']]],
  36. [account_url(@account, format: 'atom'), [['rel', 'alternate'], ['type', 'application/atom+xml']]]
  37. ])
  38. end
  39. def webfinger_account_url
  40. webfinger_url(resource: "acct:#{@account.acct}@#{Rails.configuration.x.local_domain}")
  41. end
  42. end