Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #52 from MitchTalmadge/develop
Browse files Browse the repository at this point in the history
De-spam email template.
  • Loading branch information
MitchTalmadge authored Mar 22, 2021
2 parents a159c79 + 5e96722 commit 704943a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/services/email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ConfigService } from "./config";
import nodemailer from "nodemailer";

import { ConfigService } from "./config";

export class EmailService {
public static async sendEmail(to: string, subject: string, body: string): Promise<void> {
const smtpConfig = ConfigService.getConfig().smtp;
Expand Down
11 changes: 9 additions & 2 deletions src/services/verification/verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ export abstract class VerifierService {

public sendVerificationEmail(studentId: string, user: Discord.User, code: string): Promise<void> {
console.log(`Sending verification code ${code} to ${DiscordUtils.describeUserForLogs(user)} by email.`);
const greeting = this.getRandomGreeting();
return EmailService.sendEmail(this.convertStudentIDToEmailAddress(studentId),
`[${code}] Discord Verification`,
`Hey, ${user.username}#${user.discriminator}!\n\nTo complete verification, just type the following code into the verification channel: ${code}\n\n\n(If you did not expect this email, please disregard it. Someone probably made a typo when entering their own student ID.)`
`Discord Verification Code (${code})`,
`${greeting}, ${user.username}! Here's your code for the server: ${code}. Just type it into the verification channel to continue!\n\nIf you did not expect this email, please disregard it; it was probably just the result of a typo.`
);
}

private static greetings = ["Hey", "Hi there", "Hiya", "Hello", "Howdy", "Aloha"];

private getRandomGreeting(): string {
return VerifierService.greetings[Math.floor(Math.random() * VerifierService.greetings.length - 1)];
}
}

0 comments on commit 704943a

Please sign in to comment.