mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:41:25 +08:00
Add post_edit_time_limit site setting to limit the how long a post can be edited and deleted by the author. Default is 1 year.
This commit is contained in:
@ -63,6 +63,12 @@ class PostsController < ApplicationController
|
||||
post = post.with_deleted if guardian.is_staff?
|
||||
post = post.first
|
||||
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
|
||||
|
||||
if !guardian.can_edit?(post) && post.user_id == current_user.id && post.edit_time_limit_expired?
|
||||
render json: {errors: [I18n.t('too_late_to_edit')]}, status: 422
|
||||
return
|
||||
end
|
||||
|
||||
guardian.ensure_can_edit!(post)
|
||||
|
||||
# to stay consistent with the create api,
|
||||
@ -127,6 +133,12 @@ class PostsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
post = find_post_from_params
|
||||
|
||||
if !guardian.can_delete_post?(post) && post.user_id == current_user.id && post.edit_time_limit_expired?
|
||||
render json: {errors: [I18n.t('too_late_to_edit')]}, status: 422
|
||||
return
|
||||
end
|
||||
|
||||
guardian.ensure_can_delete!(post)
|
||||
|
||||
destroyer = PostDestroyer.new(current_user, post)
|
||||
|
Reference in New Issue
Block a user