Fix #4669: Track moderation report status.
* Add ability to mark moderation reports as 'handled' or 'rejected'. * Automatically mark reports as handled when the comment or forum post is deleted. * Send a dmail to the reporter when their report is handled. * Don't show the report notice on comments or forum posts when all reports against it have been handled or rejected. * Add a fix script to mark all existing reports for deleted comments, forum posts, or dmails as handled.
This commit is contained in:
@@ -42,6 +42,6 @@ class CommentComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def reported?
|
||||
policy(ModerationReport).can_see_moderation_reports? && comment.moderation_reports.present?
|
||||
policy(ModerationReport).can_see_moderation_reports? && comment.pending_moderation_reports.present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
|
||||
<% if reported? %>
|
||||
<li class="moderation-report-notice">
|
||||
Reported (<%= link_to pluralize(comment.moderation_reports.length, "report"), moderation_reports_path(search: { model_type: "Comment", model_id: comment.id }) %>)
|
||||
Reported (<%= link_to pluralize(comment.pending_moderation_reports.length, "report"), moderation_reports_path(search: { model_type: "Comment", model_id: comment.id, status: "pending" }) %>)
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class CommentSectionComponent < ApplicationComponent
|
||||
@comments = @post.comments.order(id: :asc)
|
||||
@comments = @comments.includes(:creator)
|
||||
@comments = @comments.includes(:votes) if !current_user.is_anonymous?
|
||||
@comments = @comments.includes(:moderation_reports) if policy(ModerationReport).can_see_moderation_reports?
|
||||
@comments = @comments.includes(:pending_moderation_reports) if policy(ModerationReport).can_see_moderation_reports?
|
||||
@comments = @comments.last(limit) if limit.present?
|
||||
|
||||
@dtext_data = DText.preprocess(@comments.map(&:body))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumPostComponent < ApplicationComponent
|
||||
attr_reader :forum_post, :original_forum_post_id, :dtext_data, :moderation_reports, :current_user
|
||||
attr_reader :forum_post, :original_forum_post_id, :dtext_data, :current_user
|
||||
|
||||
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :policy, :data_attributes_for, to: :helpers
|
||||
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :data_attributes_for, to: :helpers
|
||||
|
||||
with_collection_parameter :forum_post
|
||||
|
||||
@@ -12,7 +12,7 @@ class ForumPostComponent < ApplicationComponent
|
||||
original_forum_post_id = forum_topic.original_post&.id
|
||||
|
||||
forum_posts = forum_posts.includes(:creator, :bulk_update_request)
|
||||
forum_posts = forum_posts.includes(:moderation_reports) if Pundit.policy!(current_user, ModerationReport).show?
|
||||
forum_posts = forum_posts.includes(:pending_moderation_reports) if Pundit.policy(current_user, ModerationReport).can_see_moderation_reports?
|
||||
|
||||
super(forum_posts, dtext_data: dtext_data, original_forum_post_id: original_forum_post_id, current_user: current_user)
|
||||
end
|
||||
@@ -29,7 +29,7 @@ class ForumPostComponent < ApplicationComponent
|
||||
policy(forum_post).show_deleted?
|
||||
end
|
||||
|
||||
def has_moderation_reports?
|
||||
policy(ModerationReport).can_see_moderation_reports? && forum_post.moderation_reports.present?
|
||||
def reported?
|
||||
policy(ModerationReport).can_see_moderation_reports? && forum_post.pending_moderation_reports.present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= tag.article class: "forum-post message", id: "forum_post_#{forum_post.id}", data: { "is-reported": has_moderation_reports?, **data_attributes_for(forum_post, "", forum_post.html_data_attributes) } do %>
|
||||
<%= tag.article class: "forum-post message", id: "forum_post_#{forum_post.id}", data: { "is-reported": reported?, **data_attributes_for(forum_post, "", forum_post.html_data_attributes) } do %>
|
||||
<div class="author">
|
||||
<div class="author-name">
|
||||
<%= link_to_user forum_post.creator %>
|
||||
@@ -24,8 +24,10 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if has_moderation_reports? %>
|
||||
<li class="moderation-report-notice">Reported (<%= link_to pluralize(forum_post.moderation_reports.length, "report"), moderation_reports_path(search: { model_type: "ForumPost", model_id: forum_post.id }) %>)</li>
|
||||
<% if reported? %>
|
||||
<li class="moderation-report-notice">
|
||||
Reported (<%= link_to pluralize(forum_post.pending_moderation_reports.length, "report"), moderation_reports_path(search: { model_type: "ForumPost", model_id: forum_post.id, status: "pending" }) %>)
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<%= render PopupMenuComponent.new do |menu| %>
|
||||
|
||||
Reference in New Issue
Block a user