Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ def send_welcome_email_to(user)
template_name: 'welcome_email',
)
end

def send_ban_email_to(user)
@user = user

mail(
subject: 'You Have Been Banned From The Odin Project',
to: user.email,
template_name: 'ban_email',
)
end
end
9 changes: 8 additions & 1 deletion app/models/flags/actions/ban.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
class Flags::Actions::Ban < Flags::Actions::Base
def perform
def perform # rubocop:disable Metrics/AbcSize
flag.project_submission_owner.ban!
flag.resolve(action_taken: :ban, resolved_by: admin_user)

if flag.resolved?
send_email(flag.project_submission_owner)
Result.new(success: true, message: 'Project submission owner has been banned')
else
Result.new(success: false, message: flag.errors.full_messages.join(', '))
end
end

private

def send_email(project_submission_owner)
UserMailer.send_ban_email_to(project_submission_owner).deliver_later(project_submission_owner)
end
end
101 changes: 101 additions & 0 deletions app/views/user_mailer/ban_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<!--[if !mso]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>

<body style="background-color: #fafafa; margin: 0 !important; padding: 0;">
<center class="wrapper" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; table-layout: fixed; width: 100%;">
<div class="webkit" style="margin: 0 auto 20px auto; max-width: 600px;">

<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%;">
<tr>
<td class="full-width-image center" style="padding: 0; text-align: center;">
<%= image_tag 'logo.svg', alt: 'home page banner' %>
<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>
</td>
</tr>
<tr>
<td class="one-column" style="padding: 0;">
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
<tr>
<td class="contents inner" style="background-color: #8e8e4c; padding: 10px; text-align: left; width: 100%;">
<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>
</td>
</tr>
</table>
</td>
</tr>
<tr>

</tr>

<tr>
<td class="left-sidebar" style="font-size: 0; padding: 0; text-align: left;">
<div class="column right" style="display: inline-block; max-width: 549px; vertical-align: top; width: 100%;">
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
<tr>
<td class="inner contents" style="padding: 10px; width: 100%;">
<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. </p>
</td>
</tr>
</table>
</div>

</td>
</tr>

<tr>
<td class=" one-column" style="padding: 0;">
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
<tr>
<td class="contents inner" style="text-align: left; width: 100%;">
<p class="outro-text" style="margin: 8px; color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;"> For example: </p>
<ul style="margin:0; margin-left: 25px; padding:0; font-family: Arial, sans-serif; color:#495055; font-size:16px; line-height:22px;" align="left" type="disc">
<li> One of your project submissions contained NSFW or other highly offensive images </li>
<li> One of your project submissions contained bigotry, such as racism, homophobia, hate speech </li>
<li> One of your project submissions were plagiarized </li>
</ul>

<p class="outro-text" style="margin: 8px; 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>
</td>
</tr>
</table>
</td>
</tr>

<tr>
<td class="one-column" style="padding: 0;">
<table width="100%" style="border-spacing: 0; color: #333333; font-family: sans-serif;">
<tr>
<td class="contents inner" style="padding: 10px; text-align: left; width: 100%;">
<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>
<p class="outro-text" style="color: #4a4a4a; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;">Sincerely,</p>
<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>
</td>
</tr>
</table>
</td>
</tr>

</table>

<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%;">
<tr>
<td style="padding: 0;">
&nbsp;
</td>
</tr>
</table>
</div>
</center>
</body>

</html>
8 changes: 8 additions & 0 deletions app/views/user_mailer/ban_email.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Your account has been banned because you have broken one of our rules.

For example:

One of your project submissions contained NSFW or other highly offensive images
One of your project submissions contained bigotry, such as racism, homophobia, hate speech
One of your project submissions were plagiarized
If you are unsure of the rules that were broken, you may reach out to us at [email protected]
5 changes: 5 additions & 0 deletions spec/mailers/previews/ban_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class UserMailerPreview < ActionMailer::Preview
def ban_email
UserMailer.with(user: User.first).send_ban_email_to(User.first)
end
end
Loading