Skip to content

Commit f1f7718

Browse files
committed
Added ban email feature. Related issue: #4666
1 parent e8d65ad commit f1f7718

File tree

5 files changed

+131
-1
lines changed

5 files changed

+131
-1
lines changed

app/mailers/ban_mailer.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class BanMailer < ApplicationMailer
2+
default from: 'The Odin Project <[email protected]>'
3+
4+
def send_ban_email_to(user)
5+
@user = user
6+
7+
mail(
8+
subject: 'You Have Been Banned From The Odin Project',
9+
to: user.email,
10+
template_name: 'ban_email',
11+
)
12+
end
13+
end

app/models/flags/actions/ban.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
class Flags::Actions::Ban < Flags::Actions::Base
2-
def perform
2+
def perform # rubocop:disable Metrics/AbcSize
33
flag.project_submission_owner.ban!
44
flag.resolve(action_taken: :ban, resolved_by: admin_user)
55

66
if flag.resolved?
7+
send_email(flag.project_submission_owner)
78
Result.new(success: true, message: 'Project submission owner has been banned')
89
else
910
Result.new(success: false, message: flag.errors.full_messages.join(', '))
1011
end
1112
end
13+
14+
private
15+
16+
def send_email(project_submission_owner)
17+
ban_mailer = BanMailer.new
18+
ban_mailer.send_ban_email_to(project_submission_owner)
19+
end
1220
end
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
7+
<!--[if !mso]><!-->
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
9+
<!--<![endif]-->
10+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
11+
<title></title>
12+
</head>
13+
14+
<body style="background-color: #fafafa; margin: 0 !important; padding: 0;">
15+
<center class="wrapper" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; table-layout: fixed; width: 100%;">
16+
<div class="webkit" style="margin: 0 auto 20px auto; max-width: 600px;">
17+
18+
<table class="outer" align="center" style="background-color: #ffffff; border: 1px solid black; border-spacing: 0; color: #333333; font-family: sans-serif; max-width: 600px; width: 100%;">
19+
<tr>
20+
<td class="full-width-image center" style="padding: 0; text-align: center;">
21+
<%= image_tag 'logo.svg', alt: 'home page banner' %>
22+
<p class="main-heading" style="color: #cc9543; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 28px; font-weight: bold; margin: 10px 0 20px 0; vertical-align: center;">The Odin Project</p>
23+
</td>
24+
</tr>
25+
<tr>
26+
<td class="one-column" style="padding: 0;">
27+
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
28+
<tr>
29+
<td class="contents inner" style="background-color: #8e8e4c; padding: 10px; text-align: left; width: 100%;">
30+
<p class="h1" style="color: #fff; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: 0.4px; text-align: center;">Ban Notification</p>
31+
</td>
32+
</tr>
33+
</table>
34+
</td>
35+
</tr>
36+
<tr>
37+
38+
</tr>
39+
40+
<tr>
41+
<td class="left-sidebar" style="font-size: 0; padding: 0; text-align: left;">
42+
<div class="column right" style="display: inline-block; max-width: 549px; vertical-align: top; width: 100%;">
43+
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
44+
<tr>
45+
<td class="inner contents" style="padding: 10px; width: 100%;">
46+
<p class="h3" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 24px; font-weight: bold; letter-spacing: 0.3px; margin: 8px 0 16px 0; text-align: left;"> Your account has been banned because you have broken one of our rules. For example:</p>
47+
</td>
48+
</tr>
49+
</table>
50+
</div>
51+
52+
</td>
53+
</tr>
54+
55+
<tr>
56+
<td class="one-column" style="padding: 0;">
57+
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
58+
<tr>
59+
<td class="contents inner" style="padding: 10px; text-align: left; width: 100%;">
60+
<p class="outro-text" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;">One of your project submissions contained NSFW or other highly offensive images
61+
</p>
62+
<p class="outro-text" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;"> One of your project submissions contained bigotry, such as racism, homophobia, hate speech </p>
63+
<p class="outro-text" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;"> One of your project submissions were plagiarized </p>
64+
<p class="outro-text" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;"> If you are unsure of the rules that were broken, you may reach out to us at <a href="mailto:[email protected]">[email protected]</a> </p>
65+
</td>
66+
</tr>
67+
</table>
68+
</td>
69+
</tr>
70+
71+
<tr>
72+
<td class="one-column" style="padding: 0;">
73+
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
74+
<tr>
75+
<td class="contents inner" style="padding: 10px; text-align: left; width: 100%;">
76+
<p class="outro-text bold" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: bold;">Best of luck with your learning journey!</p>
77+
<p class="outro-text" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;">Sincerely,</p>
78+
<p class="outro-text" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;"><span class="italicised" style="font-style: italic;">The Odin Maintainer Team</span></p>
79+
</td>
80+
</tr>
81+
</table>
82+
</td>
83+
</tr>
84+
85+
</table>
86+
87+
<table class="padding-table" align="center" style="background-color: #fafafa; border-spacing: 0; color: #333333; font-family: sans-serif; margin: 0; max-width: 600px; vertical-align: bottom; width: 100%;">
88+
<tr>
89+
<td style="padding: 0;">
90+
&nbsp;
91+
</td>
92+
</tr>
93+
</table>
94+
</div>
95+
</center>
96+
</body>
97+
98+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Your account has been banned because you have broken one of our rules. For example:
2+
3+
One of your project submissions contained NSFW or other highly offensive images
4+
One of your project submissions contained bigotry, such as racism, homophobia, hate speech
5+
One of your project submissions were plagiarized
6+
If you are unsure of the rules that were broken, you may reach out to us at [email protected]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class BanMailerPreview < ActionMailer::Preview
2+
def ban_email
3+
BanMailer.with(user: User.first).send_ban_email_to(User.first)
4+
end
5+
end

0 commit comments

Comments
 (0)