mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 04:58:31 -05:00
FEATURE: allow author to delete posts irrespective of post_edit_time_limit
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user