Browse Source

Fix regressions in api/v1 (#3178)

The regressions are introduced at commit
f554807563 by me (Akihiko Odaki)
closed-social-v3
Akihiko Odaki 7 years ago
committed by Eugen Rochko
parent
commit
22cb286ad7
3 changed files with 9 additions and 8 deletions
  1. +1
    -0
      app/controllers/api/v1/follow_requests_controller.rb
  2. +2
    -2
      app/controllers/api/v1/mutes_controller.rb
  3. +6
    -6
      app/controllers/api/v1/statuses_controller.rb

+ 1
- 0
app/controllers/api/v1/follow_requests_controller.rb View File

@ -9,6 +9,7 @@ class Api::V1::FollowRequestsController < ApiController
.references(:follow_requests) .references(:follow_requests)
.merge(FollowRequest.where(target_account: current_account) .merge(FollowRequest.where(target_account: current_account)
.paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])) .paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id]))
.to_a
next_path = api_v1_follow_requests_url(pagination_params(max_id: @accounts.last.follow_requests.last.id)) if @accounts.size == DEFAULT_ACCOUNTS_LIMIT next_path = api_v1_follow_requests_url(pagination_params(max_id: @accounts.last.follow_requests.last.id)) if @accounts.size == DEFAULT_ACCOUNTS_LIMIT
prev_path = api_v1_follow_requests_url(pagination_params(since_id: @accounts.first.follow_requests.first.id)) unless @accounts.empty? prev_path = api_v1_follow_requests_url(pagination_params(since_id: @accounts.first.follow_requests.first.id)) unless @accounts.empty?

+ 2
- 2
app/controllers/api/v1/mutes_controller.rb View File

@ -13,8 +13,8 @@ class Api::V1::MutesController < ApiController
.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])) .paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
.to_a .to_a
next_path = api_v1_mutes_url(pagination_params(max_id: @accounts.last.mutings.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
prev_path = api_v1_mutes_url(pagination_params(since_id: @accounts.first.mutings.first.id)) unless @accounts.empty?
next_path = api_v1_mutes_url(pagination_params(max_id: @accounts.last.mutings_accounts.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
prev_path = api_v1_mutes_url(pagination_params(since_id: @accounts.first.mutings_accounts.first.id)) unless @accounts.empty?
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
end end

+ 6
- 6
app/controllers/api/v1/statuses_controller.rb View File

@ -32,14 +32,14 @@ class Api::V1::StatusesController < ApiController
end end
def reblogged_by def reblogged_by
@accounts = Account.includes(statuses: :reblogs)
.references(statuses: :reblogs)
.where(statuses: { id: @status.id })
.merge(@status.reblogs.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
@accounts = Account.includes(:statuses)
.references(:statuses)
.merge(Status.where(reblog_of_id: @status.id)
.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
.to_a .to_a
next_path = reblogged_by_api_v1_status_url(pagination_params(max_id: @accounts.last.statuses.last.reblogs.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
prev_path = reblogged_by_api_v1_status_url(pagination_params(since_id: @accounts.first.statuses.first.reblogs.first.id)) unless @accounts.empty?
next_path = reblogged_by_api_v1_status_url(pagination_params(max_id: @accounts.last.statuses.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
prev_path = reblogged_by_api_v1_status_url(pagination_params(since_id: @accounts.first.statuses.first.id)) unless @accounts.empty?
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)

Loading…
Cancel
Save