闭社主体 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.

41 lines
879 B

  1. # frozen_string_literal: true
  2. module Api::V1::Timelines
  3. class PublicController < BaseController
  4. def show
  5. @statuses = load_statuses
  6. end
  7. private
  8. def load_statuses
  9. cached_public_statuses.tap do |statuses|
  10. set_maps(statuses)
  11. end
  12. end
  13. def cached_public_statuses
  14. cache_collection public_statuses
  15. end
  16. def public_statuses
  17. public_timeline_statuses.paginate_by_max_id(
  18. limit_param(DEFAULT_STATUSES_LIMIT),
  19. params[:max_id],
  20. params[:since_id]
  21. )
  22. end
  23. def public_timeline_statuses
  24. Status.as_public_timeline(current_account, params[:local])
  25. end
  26. def next_path
  27. api_v1_timelines_public_url pagination_params(max_id: @statuses.last.id)
  28. end
  29. def prev_path
  30. api_v1_timelines_public_url pagination_params(since_id: @statuses.first.id)
  31. end
  32. end
  33. end