about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/accounts_controller.rb34
-rw-r--r--app/controllers/api/v1/accounts/statuses_controller.rb12
2 files changed, 23 insertions, 23 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 58e176364..c4cf4a77b 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -59,14 +59,20 @@ class AccountsController < ApplicationController
   private
 
   def show_pinned_statuses?
-    [replies_requested?, media_requested?, tag_requested?, params[:max_id].present?, params[:min_id].present?].none?
+    [reblogs_requested?, replies_requested?, media_requested?, tag_requested?, params[:max_id].present?, params[:min_id].present?].none?
   end
 
   def filtered_statuses
-    default_statuses.tap do |statuses|
-      statuses.merge!(hashtag_scope)    if tag_requested?
-      statuses.merge!(only_media_scope) if media_requested?
-      statuses.merge!(no_replies_scope) unless @account.replies && replies_requested?
+    if reblogs_requested?
+      default_statuses.reblogs
+    elsif replies_requested?
+      @account.replies ? default_statuses : default_statuses.without_replies
+    elsif media_requested?
+      default_statuses.where(id: account_media_status_ids)
+    elsif tag_requested?
+      default_statuses.hashtag_scope
+    else
+      default_statuses.without_replies.without_reblogs
     end
   end
 
@@ -74,18 +80,6 @@ class AccountsController < ApplicationController
     @account.statuses.not_local_only.where(visibility: [:public, :unlisted])
   end
 
-  def only_media_scope
-    Status.where(id: account_media_status_ids)
-  end
-
-  def account_media_status_ids
-    @account.media_attachments.attached.reorder(nil).select(:status_id).distinct
-  end
-
-  def no_replies_scope
-    Status.without_replies
-  end
-
   def hashtag_scope
     tag = Tag.find_normalized(params[:tag])
 
@@ -115,6 +109,8 @@ class AccountsController < ApplicationController
       short_account_media_url(@account, max_id: max_id, min_id: min_id)
     elsif replies_requested?
       short_account_with_replies_url(@account, max_id: max_id, min_id: min_id)
+    elsif reblogs_requested?
+      short_account_reblogs_url(@account, max_id: max_id, min_id: min_id)
     else
       short_account_url(@account, max_id: max_id, min_id: min_id)
     end
@@ -128,6 +124,10 @@ class AccountsController < ApplicationController
     request.path.ends_with?('/with_replies')
   end
 
+  def reblogs_requested?
+    request.path.ends_with?('/reblogs')
+  end
+
   def tag_requested?
     request.path.ends_with?(Addressable::URI.parse("/tagged/#{params[:tag]}").normalize)
   end
diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb
index 8cd8f8e79..8a216ce0d 100644
--- a/app/controllers/api/v1/accounts/statuses_controller.rb
+++ b/app/controllers/api/v1/accounts/statuses_controller.rb
@@ -28,14 +28,14 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
 
   def account_statuses
     statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses
-    statuses = statuses.paginate_by_id(limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id))
 
-    statuses.merge!(only_media_scope) if truthy_param?(:only_media)
-    statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
-    statuses.merge!(no_reblogs_scope) if truthy_param?(:exclude_reblogs)
-    statuses.merge!(hashtag_scope)    if params[:tagged].present?
+    statuses = statuses.without_replies if !@account.replies || truthy_param?(:exclude_replies)
+    statuses = statuses.without_reblogs if truthy_param?(:exclude_reblogs)
+    statuses = statuses.reblogs if truthy_param?(:reblogs) && !truthy_param?(:exclude_reblogs)
+    statuses = statuses.where(id: account_media_status_ids) if truthy_param?(:only_media)
+    statuses = statuses.hashtag_scope if params[:tagged].present?
 
-    statuses
+    statuses.paginate_by_id(limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id))
   end
 
   def permitted_account_statuses