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.

49 lines
1.6 KiB

  1. class AccountsController < ApplicationController
  2. layout 'public'
  3. before_action :set_account
  4. before_action :set_webfinger_header
  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. if user_signed_in?
  10. status_ids = @statuses.collect { |s| [s.id, s.reblog_of_id] }.flatten.uniq
  11. @favourited = Favourite.where(status_id: status_ids).where(account_id: current_user.account_id).map { |f| [f.status_id, true] }.to_h
  12. @reblogged = Status.where(reblog_of_id: status_ids).where(account_id: current_user.account_id).map { |s| [s.reblog_of_id, true] }.to_h
  13. else
  14. @favourited = {}
  15. @reblogged = {}
  16. end
  17. end
  18. format.atom do
  19. @entries = @account.stream_entries.order('id desc').with_includes.paginate_by_max_id(20, params[:max_id] || nil)
  20. end
  21. end
  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_webfinger_header
  34. response.headers['Link'] = "<#{webfinger_account_url}>; rel=\"lrdd\"; type=\"application/xrd+xml\""
  35. end
  36. def webfinger_account_url
  37. webfinger_url(resource: "acct:#{@account.acct}@#{Rails.configuration.x.local_domain}")
  38. end
  39. end