Skip to content

Commit b31b2db

Browse files
janekhuongjoshuazhou744MikaVohltektaxi
authored andcommitted
Feat/auto emails (#949)
* Update email templates with tentative dates * Create service for sending automated status emails * Created function to find hacker by their status * API routing for automated emails * Cleaner code * API routing for getStatusCount function * Added emails.js logic to middleware and controller files * fixed authorization bug * Added hackboard role support * Revert "Added hackboard role support" This reverts commit 481d303. * update email dates --------- Co-authored-by: Joshua Zhou <[email protected]> Co-authored-by: Mika Vohl <[email protected]> Co-authored-by: Tavi Pollard <[email protected]>
1 parent f4713e7 commit b31b2db

File tree

10 files changed

+482
-144
lines changed

10 files changed

+482
-144
lines changed

app.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Services = {
88
log: require("./services/logger.service"),
99
db: require("./services/database.service"),
1010
auth: require("./services/auth.service"),
11-
env: require("./services/env.service")
11+
env: require("./services/env.service"),
1212
};
1313

1414
const envLoadResult = Services.env.load(path.join(__dirname, "./.env"));
@@ -31,6 +31,7 @@ const searchRouter = require("./routes/api/search");
3131
const settingsRouter = require("./routes/api/settings");
3232
const volunteerRouter = require("./routes/api/volunteer");
3333
const roleRouter = require("./routes/api/role");
34+
const emailsRouter = require("./routes/api/emails");
3435
const checkinRouter = require("./routes/api/checkin");
3536

3637
const app = express();
@@ -41,42 +42,40 @@ let corsOptions = {};
4142
if (!Services.env.isProduction()) {
4243
corsOptions = {
4344
origin: [`http://${process.env.FRONTEND_ADDRESS_DEV}`],
44-
credentials: true
45+
credentials: true,
4546
};
4647
} else {
4748
corsOptions = {
4849
origin: (origin, callback) => {
4950
const allowedOrigins = [
5051
`https://${process.env.FRONTEND_ADDRESS_DEPLOY}`,
5152
`https://${process.env.FRONTEND_ADDRESS_BETA}`,
52-
`https://docs.mchacks.ca`
53+
`https://docs.mchacks.ca`,
5354
];
5455

5556
const regex = /^https:\/\/dashboard-[\w-]+\.vercel\.app$/;
5657

5758
if (
5859
allowedOrigins.includes(origin) || // Explicitly allowed origins
59-
regex.test(origin) // Matches dashboard subdomains
60+
regex.test(origin) // Matches dashboard subdomains
6061
) {
6162
callback(null, true);
6263
} else {
63-
callback(new Error('Not allowed by CORS'));
64+
callback(new Error("Not allowed by CORS"));
6465
}
6566
},
66-
credentials: true
67+
credentials: true,
6768
};
6869
}
6970

70-
71-
7271
app.use(cors(corsOptions));
7372
app.use(Services.log.requestLogger);
7473
app.use(Services.log.errorLogger);
7574
app.use(express.json());
7675
app.use(
7776
express.urlencoded({
78-
extended: false
79-
})
77+
extended: false,
78+
}),
8079
);
8180
app.use(cookieParser());
8281
//Cookie-based session tracking
@@ -87,8 +86,8 @@ app.use(
8786
// Cookie Options
8887
maxAge: 48 * 60 * 60 * 1000, //Logged in for 48 hours
8988
sameSite: process.env.COOKIE_SAME_SITE,
90-
secureProxy: !Services.env.isTest()
91-
})
89+
secureProxy: !Services.env.isTest(),
90+
}),
9291
);
9392
app.use(passport.initialize());
9493
app.use(passport.session()); //persistent login session
@@ -117,12 +116,12 @@ settingsRouter.activate(apiRouter);
117116
Services.log.info("Settings router activated");
118117
roleRouter.activate(apiRouter);
119118
Services.log.info("Role router activated");
119+
emailsRouter.activate(apiRouter);
120+
Services.log.info("Emails router activated");
120121
checkinRouter.activate(apiRouter);
121122
Services.log.info("Checkin router activated");
122123

123-
apiRouter.use("/", indexRouter);
124124
app.use("/", indexRouter);
125-
126125
app.use("/api", apiRouter);
127126

128127
//Custom error handler
@@ -143,10 +142,10 @@ app.use((err, req, res) => {
143142
}
144143
res.status(status).json({
145144
message: message,
146-
data: errorContents
145+
data: errorContents,
147146
});
148147
});
149148

150149
module.exports = {
151-
app: app
150+
app: app,
152151
};

assets/email/statusEmail/Applied.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@
393393
href="https://app.mchacks.ca/"
394394
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;color:#F2463A;text-decoration:none;">hacker
395395
dashboard</a> until the deadline on <b
396-
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-weight: 700;">November
397-
17th at
396+
style="-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-weight: 700;">December
397+
1st at
398398
11:59 PM ET</b>.
399399
<br><br>
400400
In the meantime, follow us on <a href="https://instagram.com/mcgillhacks"

0 commit comments

Comments
 (0)