]> cat aescling's git repositories - mastodon.git/commitdiff
Add limit parameter to rss (#13743)
authorTakeshi Umeda <noel.yoshiba@gmail.com>
Mon, 8 Jun 2020 22:18:47 +0000 (07:18 +0900)
committerGitHub <noreply@github.com>
Mon, 8 Jun 2020 22:18:47 +0000 (00:18 +0200)
app/controllers/accounts_controller.rb
app/controllers/tags_controller.rb

index db9f45b4e9270f5261d14af54c790fa02bb4a195..62c862d36bf53d074152163210fa59faa84d7203 100644 (file)
@@ -1,7 +1,8 @@
 # frozen_string_literal: true
 
 class AccountsController < ApplicationController
-  PAGE_SIZE = 20
+  PAGE_SIZE     = 20
+  PAGE_SIZE_MAX = 200
 
   include AccountControllerConcern
   include SignatureAuthentication
@@ -40,7 +41,8 @@ class AccountsController < ApplicationController
       format.rss do
         expires_in 1.minute, public: true
 
-        @statuses = filtered_statuses.without_reblogs.limit(PAGE_SIZE)
+        limit     = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE
+        @statuses = filtered_statuses.without_reblogs.limit(limit)
         @statuses = cache_collection(@statuses, Status)
         render xml: RSS::AccountSerializer.render(@account, @statuses, params[:tag])
       end
index da0add71a91bb508c84d88bca8a4d7e5b972889d..7e86d4f1ae7d068265f5acb1ad7d55e94a71aacd 100644 (file)
@@ -3,7 +3,8 @@
 class TagsController < ApplicationController
   include SignatureVerification
 
-  PAGE_SIZE = 20
+  PAGE_SIZE     = 20
+  PAGE_SIZE_MAX = 200
 
   layout 'public'
 
@@ -25,6 +26,7 @@ class TagsController < ApplicationController
       format.rss do
         expires_in 0, public: true
 
+        limit     = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE
         @statuses = HashtagQueryService.new.call(@tag, filter_params, nil, @local).limit(PAGE_SIZE)
         @statuses = cache_collection(@statuses, Status)