FEATURE: allow author to delete posts irrespective of post_edit_time_limit

This commit is contained in:
Arpit Jalan
2018-06-26 21:43:06 +05:30
parent d81f8ea378
commit 6bcdc3ba4b
4 changed files with 1 additions and 53 deletions
+1 -10
View File
@@ -185,7 +185,7 @@ class PostsController < ApplicationController
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
if too_late_to(:edit, post)
if !guardian.send("can_edit?", post) && post.user_id == current_user.id && post.edit_time_limit_expired?
return render json: { errors: [I18n.t('too_late_to_edit')] }, status: 422
end
@@ -268,11 +268,6 @@ class PostsController < ApplicationController
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
return
end
guardian.ensure_can_delete!(post)
destroyer = PostDestroyer.new(current_user, post, context: params[:context])
@@ -691,10 +686,6 @@ class PostsController < ApplicationController
end)
end
def too_late_to(action, post)
!guardian.send("can_#{action}?", post) && post.user_id == current_user.id && post.edit_time_limit_expired?
end
def display_post(post)
post.revert_to(params[:version].to_i) if params[:version].present?
render_post_json(post)