From 19b91129d8269578f1e18a9b3a9979c91b61ac19 Mon Sep 17 00:00:00 2001 From: Jacob Herrington Date: Mon, 16 Mar 2020 17:22:00 -0500 Subject: [PATCH] Denote previously reported and suspended users in vomit reactions (#6619) [deploy] * Break feedback_messages view into partials * Standardize capitalization * Add visual cues for banned and vommitted users * Use helper methods to construct urls * Rename vomitted? to vomitted_on? vomitted_on? is a slightly more clear method name. This change takes Rhymes' suggestion to use the AR method exists? over where(...).exists? --- app/models/user.rb | 4 + .../feedback_messages/_abuse_reports.html.erb | 69 +++++++++++ .../_feedback_message.html.erb | 6 +- .../_latest_articles.html.erb | 26 ++++ .../_potential_spam_users.html.erb | 22 ++++ .../internal/feedback_messages/index.html.erb | 114 +----------------- 6 files changed, 127 insertions(+), 114 deletions(-) create mode 100644 app/views/internal/feedback_messages/_abuse_reports.html.erb create mode 100644 app/views/internal/feedback_messages/_latest_articles.html.erb create mode 100644 app/views/internal/feedback_messages/_potential_spam_users.html.erb diff --git a/app/models/user.rb b/app/models/user.rb index 33e4eb297..51a418d5a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -344,6 +344,10 @@ class User < ApplicationRecord end end + def vomitted_on? + Reaction.exists?(reactable_id: id, reactable_type: "User", category: "vomit", status: "confirmed") + end + def trusted Rails.cache.fetch("user-#{id}/has_trusted_role", expires_in: 200.hours) do has_role? :trusted diff --git a/app/views/internal/feedback_messages/_abuse_reports.html.erb b/app/views/internal/feedback_messages/_abuse_reports.html.erb new file mode 100644 index 000000000..1702ba538 --- /dev/null +++ b/app/views/internal/feedback_messages/_abuse_reports.html.erb @@ -0,0 +1,69 @@ +

Abuse Reports

+ +
+ +
+ +
+
+
+

Vomit Reactions

+ +
+
+
+ <% @vomits.each do |reaction| %> + <% next if (reaction.reactable_type == "Article" && !reaction.reactable.published) || (reaction.reactable_type == "User" && reaction.reactable&.banished?) %> +
+ + 🤢 @<%= reaction.user.username %> + + + <%= reaction.reactable_type %>: + <%= reaction.reactable.title %> + <% if reaction.reactable_type == "User" && reaction.reactable.banned %> + Suspended + <% end %> + <% if reaction.reactable_type == "User" && reaction.reactable.vomitted_on? %> + Vomitted + <% end %> + + + <% if params[:status] == "Open" || params[:status].blank? %> + <% if reaction.reactable_type == "User" %> + <%= form_for [:internal, reaction], html: { class: "d-inline" } do |f| %> + <%= f.hidden_field :status, value: "confirmed" %> + <%= f.submit "CONFIRMED", class: "btn btn-success btn-sm", data: { confirm: "Are you sure?" } %> + <% end %> + <% else %> + <%= form_for [:internal, reaction], html: { class: "d-inline" } do |f| %> + <%= f.hidden_field :status, value: "confirmed" %> + <%= f.submit "CONFIRMED", class: "btn btn-success btn-sm" %> + <% end %> + <% end %> + <%= form_for [:internal, reaction], html: { class: "d-inline" } do |f| %> + <%= f.hidden_field :status, value: "invalid" %> + <%= f.submit "INVALID", class: "btn btn-danger btn-sm" %> + <% end %> + <% end %> + +
+
+ <% end %> +
+
+
+
diff --git a/app/views/internal/feedback_messages/_feedback_message.html.erb b/app/views/internal/feedback_messages/_feedback_message.html.erb index f44ff3c7f..895cfab01 100644 --- a/app/views/internal/feedback_messages/_feedback_message.html.erb +++ b/app/views/internal/feedback_messages/_feedback_message.html.erb @@ -92,7 +92,7 @@
-

Send to:

+

Send To:

<%= email_field_tag :reporter_email_to, feedback_message.reporter&.email, class: "form-control my-1", id: "reporter__emailto__#{feedback_message.id}", required: true %>

Subject:

<%= text_field_tag :reporter_email_subject, reporter_email_details[:subject], class: "form-control my-1", id: "reporter__subject__#{feedback_message.id}" %> @@ -100,7 +100,7 @@ <%= text_area_tag :reporter_email_body, reporter_email_details[:body], class: "form-control my-1", style: "height: 300px;", id: "reporter__body__#{feedback_message.id}" %>
-

Send to:

+

Send To:

<%= email_field_tag :offender_email_to, feedback_message.offender&.email, class: "form-control my-1", id: "offender__emailto__#{feedback_message.id}", required: true %>

Subject:

<%= text_field_tag :offender_email_subject, offender_email_details[:subject], class: "form-control my-1", id: "offender__subject__#{feedback_message.id}" %> @@ -108,7 +108,7 @@ <%= text_area_tag :offender_email_body, offender_email_details[:body], class: "form-control my-1", style: "height: 300px;", id: "offender__body__#{feedback_message.id}" %>
-

Send to:

+

Send To:

<%= email_field_tag :affected_email_to, feedback_message.affected&.email, class: "form-control my-1", id: "affected__emailto__#{feedback_message.id}", required: true %>

Subject:

<%= text_field_tag :affected_email_subject, affected_email_details[:subject], class: "form-control my-1", id: "affected__subject__#{feedback_message.id}" %> diff --git a/app/views/internal/feedback_messages/_latest_articles.html.erb b/app/views/internal/feedback_messages/_latest_articles.html.erb new file mode 100644 index 000000000..7d7f40845 --- /dev/null +++ b/app/views/internal/feedback_messages/_latest_articles.html.erb @@ -0,0 +1,26 @@ +
+
+
+

Latest Articles

+ +
+
+
+ <% @new_articles.each do |article| %> + <% next if article.user.badge_achievements_count > 2 %> + <%= article.title %> + + Mod + Internal + Profile + Internal User + Destructive Actions + +
+ <% end %> +
+
+
+
diff --git a/app/views/internal/feedback_messages/_potential_spam_users.html.erb b/app/views/internal/feedback_messages/_potential_spam_users.html.erb new file mode 100644 index 000000000..50779b198 --- /dev/null +++ b/app/views/internal/feedback_messages/_potential_spam_users.html.erb @@ -0,0 +1,22 @@ +
+
+
+

Possible Spam/Abuse Users

+ +
+
+
+ <% @possible_spam_users.each do |user| %> + @<%= user.username %> - <%= user.name %> + + Internal User + Destructive Actions + +
+ <% end %> +
+
+
+
diff --git a/app/views/internal/feedback_messages/index.html.erb b/app/views/internal/feedback_messages/index.html.erb index 216dc05f4..883577059 100644 --- a/app/views/internal/feedback_messages/index.html.erb +++ b/app/views/internal/feedback_messages/index.html.erb @@ -2,119 +2,11 @@

Suspicious Activity

-
-
-
-

Latest Articles

- -
-
-
- <% @new_articles.each do |article| %> - <% next if article.user.badge_achievements_count > 2 %> - <%= article.title %> - - Mod - Internal - Profile - Internal User - Destructive Actions - -
- <% end %> -
-
-
-
+<%= render "latest_articles" %> -
-
-
-

Possible Spam/Abuse Users

- -
-
-
- <% @possible_spam_users.each do |user| %> - @<%= user.username %> - <%= user.name %> - - Internal User - Destructive Actions - -
- <% end %> -
-
-
-
+<%= render "potential_spam_users" %> -

Abuse Reports

- -
-
- -
-
- -
-
-
-

Vomit Reactions

- -
-
-
- <% @vomits.each do |reaction| %> - <% next if (reaction.reactable_type == "Article" && !reaction.reactable.published) || (reaction.reactable_type == "User" && reaction.reactable&.banished?) %> -
- - 🤢 @<%= reaction.user.username %> - - - <%= reaction.reactable_type %>: - <%= reaction.reactable.title %> - - - <% if params[:status] == "Open" || params[:status].blank? %> - <% if reaction.reactable_type == "User" %> - <%= form_for [:internal, reaction], html: { class: "d-inline" } do |f| %> - <%= f.hidden_field :status, value: "confirmed" %> - <%= f.submit "CONFIRMED", class: "btn btn-success btn-sm", data: { confirm: "Are you sure?" } %> - <% end %> - <% else %> - <%= form_for [:internal, reaction], html: { class: "d-inline" } do |f| %> - <%= f.hidden_field :status, value: "confirmed" %> - <%= f.submit "CONFIRMED", class: "btn btn-success btn-sm" %> - <% end %> - <% end %> - <%= form_for [:internal, reaction], html: { class: "d-inline" } do |f| %> - <%= f.hidden_field :status, value: "invalid" %> - <%= f.submit "INVALID", class: "btn btn-danger btn-sm" %> - <% end %> - <% end %> - -
-
- <% end %> -
-
-
-
+<%= render "abuse_reports" %> <%= search_form_for @q, url: internal_feedback_messages_path, class: "form-inline justify-content-end" do |f| %>