From 2af5cd96fee1718324061bf44f043022a3648572 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Sun, 21 May 2017 20:32:13 +0900 Subject: Fix mutes_controller error and incorrect statuses_controller report (#3202) This commit fixes a regression in commit f55480756337dd4df7513e89673e81e003f1201a. --- app/controllers/api/v1/mutes_controller.rb | 8 ++++---- app/controllers/api/v1/statuses_controller.rb | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'app/controllers/api') diff --git a/app/controllers/api/v1/mutes_controller.rb b/app/controllers/api/v1/mutes_controller.rb index 623274b96..53eb2554b 100644 --- a/app/controllers/api/v1/mutes_controller.rb +++ b/app/controllers/api/v1/mutes_controller.rb @@ -7,14 +7,14 @@ class Api::V1::MutesController < ApiController respond_to :json def index - @accounts = Account.includes(:muting) - .references(:muting) + @accounts = Account.includes(:muted_by) + .references(:muted_by) .merge(Mute.where(account: current_account) .paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])) .to_a - 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? + next_path = api_v1_mutes_url(pagination_params(max_id: @accounts.last.muted_by_ids.last)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT) + prev_path = api_v1_mutes_url(pagination_params(since_id: @accounts.first.muted_by_ids.first)) unless @accounts.empty? set_pagination_headers(next_path, prev_path) end diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 1ed51aabf..852ffc3ab 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -47,14 +47,14 @@ class Api::V1::StatusesController < ApiController end def favourited_by - @accounts = Account.includes(statuses: :favourites) - .references(statuses: :favourites) - .where(statuses: { id: @status.id }) - .merge(@status.favourites.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])) + @accounts = Account.includes(:favourites) + .references(:favourites) + .where(favourites: { status_id: @status.id }) + .merge(Favourite.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])) .to_a - next_path = favourited_by_api_v1_status_url(pagination_params(max_id: @accounts.last.statuses.last.favourites.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT) - prev_path = favourited_by_api_v1_status_url(pagination_params(since_id: @accounts.first.statuses.first.favourites.first.id)) unless @accounts.empty? + next_path = favourited_by_api_v1_status_url(pagination_params(max_id: @accounts.last.favourites.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT) + prev_path = favourited_by_api_v1_status_url(pagination_params(since_id: @accounts.first.favourites.first.id)) unless @accounts.empty? set_pagination_headers(next_path, prev_path) -- cgit