Skip to content

Commit def5481

Browse files
committed
Rename SpamReport to UserContentReport
Not only Spam will be reported. Any user content can be reported. Mailer name was adjusted to fit the naming convention.
1 parent 702d7f8 commit def5481

16 files changed

+43
-43
lines changed

app/controllers/comments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def destroy
6565
def report
6666
authorize!
6767

68-
ReportMailer.with(reported_content: @comment).report_content.deliver_later
68+
UserContentReportMailer.with(reported_content: @comment).report_content.deliver_later
6969

7070
head :no_content
7171
end

app/controllers/request_for_comments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def create
166166
def report
167167
authorize!
168168

169-
ReportMailer.with(reported_content: @request_for_comment).report_content.deliver_later
169+
UserContentReportMailer.with(reported_content: @request_for_comment).report_content.deliver_later
170170

171171
redirect_to @request_for_comment, notice: t('.reported'), status: :see_other
172172
end

app/mailers/report_mailer.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
class UserContentReportMailer < ApplicationMailer
4+
default to: CodeOcean::Config.new(:code_ocean).read.dig(:content_moderation, :report_emails)
5+
6+
def report_content
7+
@user_content_report = UserContentReport.new(reported_content: params.fetch(:reported_content))
8+
9+
mail(subject: I18n.t('user_content_report_mailer.report_content.subject', human_model_name: @user_content_report.human_model_name))
10+
end
11+
end

app/models/spam_report.rb renamed to app/models/user_content_report.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class SpamReport
3+
class UserContentReport
44
def initialize(reported_content:)
55
unless [Comment, RequestForComment].include?(reported_content.class)
66
raise("#{reported_content.model_name} is not configured for spam reports.")

app/views/report_mailer/report_content.html.slim

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/views/report_mailer/report_content.text.slim

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
h3 = t('.prolog')
2+
blockquote style="white-space: pre-wrap;" = @user_content_report.reported_message
3+
p = t('.take_action')
4+
p = link_to(request_for_comment_url(@user_content_report.related_request_for_comment), request_for_comment_url(@user_content_report.related_request_for_comment))
5+
- if @user_content_report.course_url.present?
6+
p = link_to(t('.authentication'), @user_content_report.course_url)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
== t('.prolog')
2+
== "\n\n"
3+
== @user_content_report.reported_message.lines.map { "> #{it}" }.join
4+
== "\n\n"
5+
== t('.take_action')
6+
== "\n\n"
7+
== request_for_comment_url(@user_content_report.related_request_for_comment)
8+
== "\n\n"
9+
- if @user_content_report.course_url.present?
10+
== t('.authentication')
11+
== "\n\n"
12+
== @user_content_report.course_url

config/locales/de/report.yml renamed to config/locales/de/user_content_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
de:
3-
report_mailer:
3+
user_content_report_mailer:
44
report_content:
55
authentication: Kurs-URL für die LTI-Authentifizierung.
66
prolog: 'Die folgenden Inhalte wurden als unangemessen gemeldet:'

0 commit comments

Comments
 (0)