-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature - Ban Email #4980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature - Ban Email #4980
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class BanMailer < ApplicationMailer | ||
default from: 'The Odin Project <[email protected]>' | ||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
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) | ||
ban_mailer = BanMailer.new | ||
ban_mailer.send_ban_email_to(project_submission_owner) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think this will wait until the email is sent within the same request/response cycle, slowing the response down. We can send the email in the background instead: UserMailer.send_ban_email_to(project_submission_owner).deliver_later |
||
end | ||
end |
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"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've left some minor feedback about the email content on the issue. |
||
<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;"> | ||
| ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</center> | ||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Can we add a new line above this please? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class BanMailerPreview < ActionMailer::Preview | ||
def ban_email | ||
BanMailer.with(user: User.first).send_ban_email_to(User.first) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Because this is a user related email, I think it should live in the
UserMailer
along side the welcome email.