moderation reports: pass CurrentUser to visible explicitly.

This is for consistency with how `visible` works in other models.
This commit is contained in:
evazion
2020-03-21 22:14:45 -05:00
parent 2445e8b82f
commit 94aff2c777
5 changed files with 8 additions and 8 deletions

View File

@@ -77,7 +77,7 @@ class ModerationReport < ApplicationRecord
end
end
def self.visible(user = CurrentUser.user)
def self.visible(user)
user.is_moderator? ? all : none
end

View File

@@ -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)), moderation_reports: @post.moderation_reports.visible.recent })) %>");
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: @post.moderation_reports.visible(CurrentUser.user).recent })) %>");
$(window).trigger("danbooru:index_for_post", [<%= @post.id %>]);

View File

@@ -3,10 +3,10 @@
<%= render "comments/partials/index/header", :post => post %>
<% end %>
<% if post.moderation_reports.visible.recent.present? %>
<% if post.moderation_reports.visible(CurrentUser.user).recent.present? %>
<div class="row moderation-comments-notice">
<span class="info" id="moderation-comments-notice-for-<%= post.id %>">
This post has comments reported for moderation! (<%= pluralize(post.moderation_reports.visible.recent.length, "report") %>)
This post has comments reported for moderation! (<%= pluralize(post.moderation_reports.visible(CurrentUser.user).recent.length, "report") %>)
</span>
</div>
<% end %>
@@ -20,7 +20,7 @@
<div class="list-of-comments list-of-messages">
<% if comments.present? %>
<%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)), moderation_reports: post.moderation_reports.visible.recent } %>
<%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)), moderation_reports: post.moderation_reports.visible(CurrentUser.user).recent } %>
<% elsif post.last_commented_at.present? %>
<p>There are no visible comments.</p>
<% else %>

View File

@@ -26,7 +26,7 @@
</div>
<% 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)), moderation_reports: @forum_topic.moderation_reports.visible.recent %>
<%= 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: @forum_topic.moderation_reports.visible(CurrentUser.user).recent %>
<% if policy(ForumPost.new(topic: @forum_topic)).create? %>
<p><%= link_to "Post reply", new_forum_post_path(topic_id: @forum_topic.id), id: "new-response-link" %></p>

View File

@@ -5,10 +5,10 @@
<div id="a-show">
<h1><%= link_to_user @user %></h1>
<% if @user.moderation_reports.visible.recent.present? %>
<% if @user.moderation_reports.visible(CurrentUser.user).recent.present? %>
<div class="moderation-users-notice">
<span class="info" id="moderation-users-notice-for-<%= @user.id %>">
This user has been reported for moderation! (<%= pluralize(@user.moderation_reports.visible.recent.length, "report") %>)
This user has been reported for moderation! (<%= pluralize(@user.moderation_reports.visible(CurrentUser.user).recent.length, "report") %>)
</span>
</div>
<% end %>