-
Notifications
You must be signed in to change notification settings - Fork 0
/
messageTemplates.js
168 lines (148 loc) Β· 4.72 KB
/
messageTemplates.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Doc to store all of the different types of email templates we have.
const util = require('util');
const EmailType =
{
MemberRequested: 1,
MemberApproved: 2,
MemberDenied: 3
}
const EmailMessages = {};
EmailMessages[EmailType.MemberRequested] =
{
subject: `π₯ %s Requested to Join Your Team π₯`,
html: `
<center>
<h2>Hey %s,</h2>
<br>
<h1>You've got a pending teammate request!</h1>
<br><br>
<h2>%s (%s) has requested to join your team.<h2>
<br>
<h3>%s right now, trying to join your team:</h3>
<br>
<img src='https://i.imgur.com/cvM7SpS.png' />
<br>
<h3>Here's what they wrote:<h3>
<br>
<blockquote>%s</blockquote>
<br>
<h2>
Head to <a href='hackdavis.io'>hackdavis.io</a> to approve or deny the request.
<br>
Happy hacking! You can reply to this email if you have any questions.
<br><br>
<i>- The HackDavis Team</i> π
</h2>
<br>
<br>
</center>
`
}
EmailMessages[EmailType.MemberApproved] = {
subject: `β¨ Your Request to Join %s has Been Approved β¨`,
html: `
<center>
<h2>Hey %s,</h2>
<br>
<h1>You've been accepted to %s!</h1>
<br>
<img src='https://i.imgur.com/ZCcuU0J.png'/>
<br><br>
<h2> Head to <a href='hackdavis.io'>hackdavis.io</a> to check out your new team!
<br>
Happy hacking! You can reply to this email if you have any questions.
<br><br>
<i>- The HackDavis Team</i> π
</h2>
<br>
<br>
</center>
`
}
EmailMessages[EmailType.MemberDenied] = {
subject: `β Your Request to Join %s has Expired β`,
html: `
<center>
<h2>Hey %s,</h2>
<br>
<h1>Oh no! It looks like your request to join %s has expired.</h1>
<img src='https://i.imgur.com/KSQr6EN.jpg' />
<h3>This could be due to several reasons, such as:</h3>
<p>
You joining/creating a different team<br>
Your request to join being denied or cancelled<br>
The team you requested being disbanded
</p>
<br><br>
<h2>Don't worry - you can head to <a href='hackdavis.io'>hackdavis.io</a> to keep on browsing for more teams!
<br>
Happy hacking! You can reply to this email if you have any questions.
<br><br>
<i>- The HackDavis Team</i> π
</h2>
<br>
<br>
</center>
`
}
/**
* Formats an email based on the data provided.a
*
* data must contain:
* emailType (type of email being sent)
*
* The rest of the data is based on emailType.
*
* For emailType = EmailType.MemberRequested then you must include:
* member_name (string): name of member who requested to join
* member_email (string): email of member who requested to join
* member_message (string): message that the member wrote to join
* team_member_emails (array): array of current team member emails
* team_name (string): string of the team name
*/
function FormatEmail(data)
{
switch (data.emailType)
{
// A member requested to join this team
case EmailType.MemberRequested:
{
return {
subject: util.format(EmailMessages[data.emailType].subject,
data.member_name),
html: util.format(EmailMessages[data.emailType].html,
data.team_name,
data.member_name,
data.member_email,
data.member_name,
data.member_message),
to: data.team_member_emails
};
}
// A member was accepted to this team
case EmailType.MemberApproved:
{
return {
subject: util.format(EmailMessages[data.emailType].subject,
data.team_name),
html: util.format(EmailMessages[data.emailType].html,
data.member_name,
data.team_name),
to: data.member_email
};
}
// A member was denied to this team
case EmailType.MemberDenied:
{
return {
subject: util.format(EmailMessages[data.emailType].subject,
data.team_name),
html: util.format(EmailMessages[data.emailType].html,
data.member_name,
data.team_name),
to: data.member_email
};
}
}
}
module.exports = {EmailType, FormatEmail}