mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
FIX: prevent re-flagging when we have reviewed flags before (#10010)
FIX: prevent re-flagging when we have reviewed flags before Fixes an edge case where a review can be reflagged when: User flags as inappropriate. Moderator rejects the flag. Another user re-flags the post as spam. Before, anyone was able to re-flag as inappropriate despite it being flagged previously. With this, users are unable to re-flag for the same reason regardless of reviewable status.
This commit is contained in:
@ -141,11 +141,11 @@ private
|
||||
|
||||
def cannot_flag_again?(reviewable)
|
||||
return false if @post_action_type_id == PostActionType.types[:notify_moderators]
|
||||
flag_type_already_used = reviewable.reviewable_scores.any? { |rs| rs.reviewable_score_type == @post_action_type_id }
|
||||
flag_type_already_used = reviewable.reviewable_scores.any? { |rs| rs.reviewable_score_type == @post_action_type_id && rs.status != ReviewableScore.statuses[:pending] }
|
||||
not_edited_since_last_review = @post.last_version_at.blank? || reviewable.updated_at > @post.last_version_at
|
||||
handled_recently = reviewable.updated_at > SiteSetting.cooldown_hours_until_reflag.to_i.hours.ago
|
||||
|
||||
!reviewable.pending? && flag_type_already_used && not_edited_since_last_review && handled_recently
|
||||
flag_type_already_used && not_edited_since_last_review && handled_recently
|
||||
end
|
||||
|
||||
def notify_subscribers
|
||||
|
Reference in New Issue
Block a user