about summary refs log tree commit diff
path: root/app/controllers/api/v1
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-08-27 17:30:42 +0200
committerThibaut Girka <thib@sitedethib.com>2018-08-27 18:09:28 +0200
commit53b7bb9d047cfc8b21ee0540bd3e5285267160fd (patch)
tree30dcf8694eadb68ca8a9579e312f9c38ad8c09d1 /app/controllers/api/v1
parentaf934b90710a2ce1099d3ceda5de7bcf0e94595c (diff)
parent81697997a3fdbb481202a179908958198baaf0dd (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
	app/controllers/api/v1/mutes_controller.rb
	config/locales/simple_form.pl.yml
Diffstat (limited to 'app/controllers/api/v1')
-rw-r--r--app/controllers/api/v1/lists/accounts_controller.rb2
-rw-r--r--app/controllers/api/v1/lists_controller.rb2
-rw-r--r--app/controllers/api/v1/mutes_controller.rb24
3 files changed, 13 insertions, 15 deletions
diff --git a/app/controllers/api/v1/lists/accounts_controller.rb b/app/controllers/api/v1/lists/accounts_controller.rb
index 19de56732..ec4477034 100644
--- a/app/controllers/api/v1/lists/accounts_controller.rb
+++ b/app/controllers/api/v1/lists/accounts_controller.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class Api::V1::Lists::AccountsController < Api::BaseController
-  before_action -> { doorkeeper_authorize! :read, :'read:lists' },    only:  [:show]
+  before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:show]
   before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:show]
 
   before_action :require_user!
diff --git a/app/controllers/api/v1/lists_controller.rb b/app/controllers/api/v1/lists_controller.rb
index b42b8b971..054172bee 100644
--- a/app/controllers/api/v1/lists_controller.rb
+++ b/app/controllers/api/v1/lists_controller.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class Api::V1::ListsController < Api::BaseController
-  before_action -> { doorkeeper_authorize! :read, :'read:lists' },    only:  [:index, :show]
+  before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:index, :show]
   before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:index, :show]
 
   before_action :require_user!
diff --git a/app/controllers/api/v1/mutes_controller.rb b/app/controllers/api/v1/mutes_controller.rb
index aea94d553..3b3a39943 100644
--- a/app/controllers/api/v1/mutes_controller.rb
+++ b/app/controllers/api/v1/mutes_controller.rb
@@ -20,11 +20,7 @@ class Api::V1::MutesController < Api::BaseController
   private
 
   def load_accounts
-    default_accounts.merge(paginated_mutes).to_a
-  end
-
-  def default_accounts
-    Account.includes(:muted_by).references(:muted_by)
+    paginated_mutes.map(&:target_account)
   end
 
   def load_mutes
@@ -32,11 +28,13 @@ class Api::V1::MutesController < Api::BaseController
   end
 
   def paginated_mutes
-    Mute.where(account: current_account).paginate_by_max_id(
-      limit_param(DEFAULT_ACCOUNTS_LIMIT),
-      params[:max_id],
-      params[:since_id]
-    )
+    @paginated_mutes ||= Mute.eager_load(:target_account)
+                             .where(account: current_account)
+                             .paginate_by_max_id(
+                               limit_param(DEFAULT_ACCOUNTS_LIMIT),
+                               params[:max_id],
+                               params[:since_id]
+                             )
   end
 
   def insert_pagination_headers
@@ -50,7 +48,7 @@ class Api::V1::MutesController < Api::BaseController
   end
 
   def prev_path
-    unless@data.empty?
+    unless @data.empty?
       url_for pagination_params(since_id: pagination_since_id)
     end
   end
@@ -59,7 +57,7 @@ class Api::V1::MutesController < Api::BaseController
     if params[:action] == "details"
       @mutes.last.id
     else
-      @accounts.last.muted_by_ids.last
+      paginated_mutes.last.id
     end
   end
 
@@ -67,7 +65,7 @@ class Api::V1::MutesController < Api::BaseController
     if params[:action] == "details"
       @mutes.first.id
     else
-      @accounts.first.muted_by_ids.first
+      paginated_mutes.first.id
     end
   end