闭社主体 forked from https://github.com/tootsuite/mastodon
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.

44 lines
927 B

  1. # frozen_string_literal: true
  2. module Api::V1::Timelines
  3. class HomeController < BaseController
  4. before_action -> { doorkeeper_authorize! :read }, only: [:show]
  5. before_action :require_user!, only: [:show]
  6. def show
  7. @statuses = load_statuses
  8. end
  9. private
  10. def load_statuses
  11. cached_home_statuses.tap do |statuses|
  12. set_maps(statuses)
  13. end
  14. end
  15. def cached_home_statuses
  16. cache_collection home_statuses
  17. end
  18. def home_statuses
  19. account_home_feed.get(
  20. limit_param(DEFAULT_STATUSES_LIMIT),
  21. params[:max_id],
  22. params[:since_id]
  23. )
  24. end
  25. def account_home_feed
  26. Feed.new(:home, current_account)
  27. end
  28. def next_path
  29. api_v1_timelines_home_url pagination_params(max_id: @statuses.last.id)
  30. end
  31. def prev_path
  32. api_v1_timelines_home_url pagination_params(since_id: @statuses.first.id)
  33. end
  34. end
  35. end