Skip to content
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

Add admin fyi for batch emails #236

Merged
merged 4 commits into from
Sep 7, 2018
Merged
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "registration",
"version": "2.3.1",
"version": "2.3.2",
"description": "Powerful and extensible registration system for hackathons and other large events",
"main": "server/app.js",
"scripts": {
Expand Down
18 changes: 17 additions & 1 deletion server/routes/api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ settingsRoutes.route("/email_content/:type/rendered")
settingsRoutes.route("/send_batch_email")
.post(isAdmin, uploadHandler.any(), async (request, response) => {
let filter = JSON.parse(request.body.filter);
let subject = request.body.subject;
let subject = request.body.subject as string;
let markdownContent = request.body.markdownContent;
if (typeof filter !== "object") {
return response.status(400).json({
Expand Down Expand Up @@ -313,6 +313,22 @@ settingsRoutes.route("/send_batch_email")
text
});
}

let admins = await User.find({ admin: true });
for (let user of admins) {
let html: string = await renderEmailHTML(markdownContent, user);
let text: string = await renderEmailText(html, user, true);
subject = `[Admin FYI] ${subject}`;
text = `${filter.toString()}\n${text}`;
text = `${filter.toString()}<br>${text}`;
emails.push({
from: config.email.from,
to: user.email,
subject,
html,
text
});
}
try {
await sendBatchMailAsync(emails);
} catch (e) {
Expand Down