FIX: Tighter rate-limit for post self-deletions

This commit is contained in:
Kane York 2015-08-18 12:49:54 -07:00
parent 707c493e3c
commit 94439ebddd

View File

@ -184,6 +184,7 @@ class PostsController < ApplicationController
def destroy
post = find_post_from_params
RateLimiter.new(current_user, "delete_post", 3, 1.minute).performed! unless current_user.staff?
if too_late_to(:delete_post, post)
render json: {errors: [I18n.t('too_late_to_edit')]}, status: 422
@ -206,6 +207,7 @@ class PostsController < ApplicationController
def recover
post = find_post_from_params
RateLimiter.new(current_user, "delete_post", 3, 1.minute).performed! unless current_user.staff?
guardian.ensure_can_recover_post!(post)
destroyer = PostDestroyer.new(current_user, post)
destroyer.recover