api: add rate limit to /posts.atom endpoint.

Add a rate limit of 1 request per 2 seconds to the post RSS feed
endpoint (/posts.atom).

This lets you check your feeds 30 times per minute, or 1800 times per
hour. The previous limit was 10 requests per second.

This is because there are too many bad RSS feed reader bots constantly
checking the same tags over and over again, 24 hours a day, as fast
they can.
This commit is contained in:
evazion
2021-12-09 21:47:28 -06:00
parent 2e9f4dc2f4
commit 36985e9590

View File

@@ -2,6 +2,8 @@ class PostsController < ApplicationController
respond_to :html, :xml, :json, :js
layout "sidebar"
rate_limit :index, rate: 1.0/2.seconds, burst: 50, if: -> { request.format.atom? }, key: "posts:index.atom"
def index
if params[:md5].present?
@post = authorize Post.find_by!(md5: params[:md5])