diff --git a/app/javascript/src/styles/specific/comments.scss b/app/javascript/src/styles/specific/comments.scss index 42e9fe5a8..2415df4ae 100644 --- a/app/javascript/src/styles/specific/comments.scss +++ b/app/javascript/src/styles/specific/comments.scss @@ -1,6 +1,12 @@ @import "../base/000_vars.scss"; div.comments-for-post { + div.moderation-comments-notice { + margin: 1em 0; + font-weight: bold; + color: red; + } + div.hidden-comments-notice { margin: 1em 0; } @@ -13,6 +19,10 @@ div.comments-for-post { background: var(--comment-sticky-background-color); } + &[data-is-reported="true"] { + border: solid red; + } + &[data-is-voted="true"] { .comment-vote-up-link, .comment-vote-down-link { display: none; diff --git a/app/javascript/src/styles/specific/forum.scss b/app/javascript/src/styles/specific/forum.scss index 8cc4bab06..e5ec634e3 100644 --- a/app/javascript/src/styles/specific/forum.scss +++ b/app/javascript/src/styles/specific/forum.scss @@ -1,5 +1,14 @@ div.list-of-forum-posts { + div.moderation-forums-notice { + font-weight: bold; + color: red; + } + article.forum-post { + &[data-is-reported="true"] { + border: solid red; + } + a.voted { font-weight: bold; } diff --git a/app/javascript/src/styles/specific/users.scss b/app/javascript/src/styles/specific/users.scss index cfa0c5579..3f5ab44aa 100644 --- a/app/javascript/src/styles/specific/users.scss +++ b/app/javascript/src/styles/specific/users.scss @@ -1,5 +1,11 @@ div#c-users { div#a-show { + div.moderation-users-notice { + margin: 1em 0; + font-weight: bold; + color: red; + } + div.box { margin-bottom: 2em; } diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index 458aad16d..2f47dfe30 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -181,4 +181,9 @@ class ForumTopic < ApplicationRecord def update_orignal_post original_post&.update_columns(:updater_id => CurrentUser.id, :updated_at => Time.now) end + + def moderation_reports + posts_with_reports = posts.joins(:moderation_reports).includes(:moderation_reports).distinct + posts_with_reports.reduce([]) {|arr,post| arr + post.moderation_reports} + end end diff --git a/app/models/post.rb b/app/models/post.rb index 6b7326079..3f66bc21c 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1811,4 +1811,11 @@ class Post < ApplicationRecord save end + + def moderation_reports + @moderation_reports ||= begin + comments_with_reports = comments.joins(:moderation_reports).includes(:moderation_reports).distinct + comments_with_reports.reduce([]) {|arr,comment| arr + comment.moderation_reports} + end + end end diff --git a/app/views/comments/_index_by_comment.html.erb b/app/views/comments/_index_by_comment.html.erb index e70882dfa..478c06557 100644 --- a/app/views/comments/_index_by_comment.html.erb +++ b/app/views/comments/_index_by_comment.html.erb @@ -8,7 +8,7 @@ <%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %> <% end %> - <%= render partial: "comments/partials/show/comment", collection: [comment], locals: { context: :index_by_comment, dtext_data: DText.preprocess(@comments.map(&:body)) } %> + <%= render partial: "comments/partials/show/comment", collection: [comment], locals: { context: :index_by_comment, dtext_data: DText.preprocess(@comments.map(&:body)), moderation_reports: [] } %> <% end %> <% end %> <% end %> diff --git a/app/views/comments/index_for_post.js.erb b/app/views/comments/index_for_post.js.erb index af2b8cab0..b92960a47 100644 --- a/app/views/comments/index_for_post.js.erb +++ b/app/views/comments/index_for_post.js.erb @@ -1,5 +1,5 @@ $("#threshold-comments-notice-for-<%= @post.id %>").hide(); var current_comment_section = $("div.comments-for-post[data-post-id=<%= @post.id %>] div.list-of-comments"); -current_comment_section.html("<%= j(render(partial: 'comments/partials/show/comment', collection: @comments, locals: { context: :index_for_post, dtext_data: DText.preprocess(@comments.map(&:body)) })) %>"); +current_comment_section.html("<%= j(render(partial: 'comments/partials/show/comment', collection: @comments, locals: { context: :index_for_post, dtext_data: DText.preprocess(@comments.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? @post.moderation_reports : []) })) %>"); $(window).trigger("danbooru:index_for_post", [<%= @post.id %>]); diff --git a/app/views/comments/partials/index/_list.html.erb b/app/views/comments/partials/index/_list.html.erb index be56922dd..5bdacd0c0 100644 --- a/app/views/comments/partials/index/_list.html.erb +++ b/app/views/comments/partials/index/_list.html.erb @@ -3,6 +3,13 @@ <%= render "comments/partials/index/header", :post => post %> <% end %> + <% if CurrentUser.is_moderator? && post.moderation_reports.any? %> +
+ + This post has comments reported for moderation! (<%= post.moderation_reports.count %> <%= (post.moderation_reports.count == 1 ? "report" : "reports") %>) + +
+ <% end %> <% if post.comments.hidden(CurrentUser.user).any? || (page == :comments && post.comments.size > 6) %>
@@ -13,7 +20,7 @@
<% if comments.present? %> - <%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)) } %> + <%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? post.moderation_reports : []) } %> <% elsif post.last_commented_at.present? %>

There are no visible comments.

<% else %> diff --git a/app/views/comments/partials/show/_comment.html.erb b/app/views/comments/partials/show/_comment.html.erb index acf2c60ad..8205ae503 100644 --- a/app/views/comments/partials/show/_comment.html.erb +++ b/app/views/comments/partials/show/_comment.html.erb @@ -1,4 +1,4 @@ -<%# locals: comment, context, dtext_data %> +<%# locals: comment, context, dtext_data, moderation_reports %> <% if CurrentUser.is_moderator? || (params[:search] && params[:search][:is_deleted] =~ /t/) || !comment.is_deleted? %> @@ -12,6 +12,9 @@ data-is-deleted="<%= comment.is_deleted? %>" data-is-sticky="<%= comment.is_sticky? %>" data-below-threshold="<%= comment.score < CurrentUser.user.comment_threshold %>" + <% if CurrentUser.is_moderator? %> + data-is-reported="<%= moderation_reports.pluck(:model_id).include?(comment.id) %>" + <% end %> data-is-voted="<%= comment.voted_by?(CurrentUser.user) %>">

diff --git a/app/views/forum_posts/_forum_post.html.erb b/app/views/forum_posts/_forum_post.html.erb index 73726f3bd..32fb3c166 100644 --- a/app/views/forum_posts/_forum_post.html.erb +++ b/app/views/forum_posts/_forum_post.html.erb @@ -1,5 +1,10 @@ <% if forum_post.visible?(CurrentUser.user, ActiveModel::Type::Boolean.new.cast(params.dig(:search, :is_deleted))) %> -
+
+ data-is-reported="<%= moderation_reports.pluck(:model_id).include?(forum_post.id) %>" + <% end %> + data-creator="<%= forum_post.creator.name %>">

<%= link_to_user forum_post.creator %> diff --git a/app/views/forum_posts/_listing.html.erb b/app/views/forum_posts/_listing.html.erb index 0612f2522..e6b57147d 100644 --- a/app/views/forum_posts/_listing.html.erb +++ b/app/views/forum_posts/_listing.html.erb @@ -1,9 +1,18 @@ <%- # forum_post %> <%- # original_forum_post_id %> <%- # dtext_data %> +<%- # moderation_reports %>
+ <% if CurrentUser.is_moderator? && moderation_reports.any? %> +
+ + This topic has forum posts reported for moderation! (<%= moderation_reports.count %> <%= (moderation_reports.count == 1 ? "report" : "reports") %>) + +
+ <% end %> + <% forum_posts.each do |forum_post| %> - <%= render "forum_posts/forum_post", forum_post: forum_post, original_forum_post_id: original_forum_post_id, dtext_data: dtext_data %> + <%= render "forum_posts/forum_post", forum_post: forum_post, original_forum_post_id: original_forum_post_id, dtext_data: dtext_data, moderation_reports: moderation_reports %> <% end %>
diff --git a/app/views/forum_topics/show.html.erb b/app/views/forum_topics/show.html.erb index c8d64d5dc..8d662875c 100644 --- a/app/views/forum_topics/show.html.erb +++ b/app/views/forum_topics/show.html.erb @@ -20,7 +20,7 @@

<% end %> - <%= render "forum_posts/listing", forum_posts: @forum_posts, original_forum_post_id: @forum_topic.original_post.id, dtext_data: DText.preprocess(@forum_posts.map(&:body)) %> + <%= render "forum_posts/listing", forum_posts: @forum_posts, original_forum_post_id: @forum_topic.original_post.id, dtext_data: DText.preprocess(@forum_posts.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? @forum_topic.moderation_reports : []) %> <% if CurrentUser.is_member? %> <% if CurrentUser.is_moderator? || !@forum_topic.is_locked? %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 665b2b5d1..893eba77f 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -2,6 +2,14 @@

<%= link_to_user @user %>

+ <% if !@user.is_moderator? && CurrentUser.is_moderator? && @user.moderation_reports.any? %> +
+ + This user has been reported for moderation! (<%= @user.moderation_reports.count %> <%= (@user.moderation_reports.count == 1 ? "report" : "reports") %>) + +
+ <% end %> + <%= render "statistics", presenter: @user.presenter, user: @user %> <%= render "posts/partials/common/inline_blacklist" %>