about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-05-24 06:26:23 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-23 23:26:23 +0200
commit3ce9ca4c99c9403125ea2b23690a274b05dfd2ac (patch)
tree3cda23b8ef73ed58d4a2ed32d5e29750dc2d81a3 /app/controllers/api
parent2ca1f0737a42f2943e8cf063f16eac5f93df2ed3 (diff)
Fix following/followers API to return correct link headers (#3268)
Link headers in following/followers API should include follow_id as max_id/since_id.

However, these API use current_user's account_id instead of follow_id from #3167.
This causes irrelevant result on loading more users.
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/accounts_controller.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb
index 664ac0ba5..d323522ff 100644
--- a/app/controllers/api/v1/accounts_controller.rb
+++ b/app/controllers/api/v1/accounts_controller.rb
@@ -23,14 +23,14 @@ class Api::V1::AccountsController < ApiController
   end
 
   def following
-    @accounts = Account.includes(:followers)
-                       .references(:followers)
+    @accounts = Account.includes(:passive_relationships)
+                       .references(:passive_relationships)
                        .merge(Follow.where(account: @account)
                                     .paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
                        .to_a
 
-    next_path = following_api_v1_account_url(pagination_params(max_id: @accounts.last.followers.last.id))     if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
-    prev_path = following_api_v1_account_url(pagination_params(since_id: @accounts.first.followers.first.id)) unless @accounts.empty?
+    next_path = following_api_v1_account_url(pagination_params(max_id: @accounts.last.passive_relationships.first.id))     if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
+    prev_path = following_api_v1_account_url(pagination_params(since_id: @accounts.first.passive_relationships.first.id)) unless @accounts.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -38,16 +38,16 @@ class Api::V1::AccountsController < ApiController
   end
 
   def followers
-    @accounts = Account.includes(:following)
-                       .references(:following)
+    @accounts = Account.includes(:active_relationships)
+                       .references(:active_relationships)
                        .merge(Follow.where(target_account: @account)
                                     .paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT),
                                                         params[:max_id],
                                                         params[:since_id]))
                        .to_a
 
-    next_path = followers_api_v1_account_url(pagination_params(max_id: @accounts.last.following.last.id))     if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
-    prev_path = followers_api_v1_account_url(pagination_params(since_id: @accounts.first.following.first.id)) unless @accounts.empty?
+    next_path = followers_api_v1_account_url(pagination_params(max_id: @accounts.last.active_relationships.first.id))     if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
+    prev_path = followers_api_v1_account_url(pagination_params(since_id: @accounts.first.active_relationships.first.id)) unless @accounts.empty?
 
     set_pagination_headers(next_path, prev_path)