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.

52 lines
1.5 KiB

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