FIX: Only unhide flagged post if editor is the author
Also, rename @user to @editor in PostRevisor
This commit is contained in:
parent
4814659b7b
commit
7a843d2ac2
|
@ -8,10 +8,17 @@ class PostRevisor
|
|||
@post = post
|
||||
end
|
||||
|
||||
def revise!(user, new_raw, opts = {})
|
||||
@user, @new_raw, @opts = user, new_raw, opts
|
||||
return false if not should_revise?
|
||||
@post.acting_user = @user
|
||||
# Recognized options:
|
||||
# :edit_reason User-supplied edit reason
|
||||
# :revised_at changes the date of the revision
|
||||
# :force_new_version bypass ninja-edit window
|
||||
# :bypass_bump do not bump the topic, even if last post
|
||||
# :skip_validation ask ActiveRecord to skip validations
|
||||
#
|
||||
def revise!(editor, new_raw, opts = {})
|
||||
@editor, @new_raw, @opts = editor, new_raw, opts
|
||||
return false unless should_revise?
|
||||
@post.acting_user = @editor
|
||||
revise_post
|
||||
update_category_description
|
||||
update_topic_excerpt
|
||||
|
@ -54,7 +61,7 @@ class PostRevisor
|
|||
end
|
||||
|
||||
def should_create_new_version?
|
||||
@post.last_editor_id != @user.id ||
|
||||
@post.last_editor_id != @editor.id ||
|
||||
get_revised_at - @post.last_version_at > SiteSetting.ninja_edit_window.to_i ||
|
||||
@opts[:force_new_version] == true
|
||||
end
|
||||
|
@ -64,7 +71,7 @@ class PostRevisor
|
|||
@post.version += 1
|
||||
@post.last_version_at = get_revised_at
|
||||
update_post
|
||||
EditRateLimiter.new(@user).performed! unless @opts[:bypass_rate_limiter] == true
|
||||
EditRateLimiter.new(@editor).performed! unless @opts[:bypass_rate_limiter] == true
|
||||
bump_topic unless @opts[:bypass_bump]
|
||||
end
|
||||
end
|
||||
|
@ -84,10 +91,10 @@ class PostRevisor
|
|||
def update_post
|
||||
@post.raw = @new_raw
|
||||
@post.word_count = @new_raw.scan(/\w+/).size
|
||||
@post.last_editor_id = @user.id
|
||||
@post.last_editor_id = @editor.id
|
||||
@post.edit_reason = @opts[:edit_reason] if @opts[:edit_reason]
|
||||
|
||||
if @post.hidden && @post.hidden_reason_id == Post.hidden_reasons[:flag_threshold_reached]
|
||||
if @editor == @post.user && @post.hidden && @post.hidden_reason_id == Post.hidden_reasons[:flag_threshold_reached]
|
||||
@post.hidden = false
|
||||
@post.hidden_reason_id = nil
|
||||
@post.topic.update_attributes(visible: true)
|
||||
|
|
Loading…
Reference in New Issue