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

Commit 704943a

Browse files
Merge pull request #52 from MitchTalmadge/develop
De-spam email template.
2 parents a159c79 + 5e96722 commit 704943a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/services/email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { ConfigService } from "./config";
21
import nodemailer from "nodemailer";
32

3+
import { ConfigService } from "./config";
4+
45
export class EmailService {
56
public static async sendEmail(to: string, subject: string, body: string): Promise<void> {
67
const smtpConfig = ConfigService.getConfig().smtp;

src/services/verification/verifier.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ export abstract class VerifierService {
1919

2020
public sendVerificationEmail(studentId: string, user: Discord.User, code: string): Promise<void> {
2121
console.log(`Sending verification code ${code} to ${DiscordUtils.describeUserForLogs(user)} by email.`);
22+
const greeting = this.getRandomGreeting();
2223
return EmailService.sendEmail(this.convertStudentIDToEmailAddress(studentId),
23-
`[${code}] Discord Verification`,
24-
`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.)`
24+
`Discord Verification Code (${code})`,
25+
`${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.`
2526
);
2627
}
28+
29+
private static greetings = ["Hey", "Hi there", "Hiya", "Hello", "Howdy", "Aloha"];
30+
31+
private getRandomGreeting(): string {
32+
return VerifierService.greetings[Math.floor(Math.random() * VerifierService.greetings.length - 1)];
33+
}
2734
}
2835

0 commit comments

Comments
 (0)