Skip to content

Commit 39acdfa

Browse files
committed
fix: assign email
1 parent 4e0bf89 commit 39acdfa

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/routes/copilotOpportunity/assign.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,7 @@ module.exports = [
3232
return next(err);
3333
}
3434

35-
const sendEmailToAllApplicants = async (opportunity, copilotRequest, applicationId) => {
36-
const allApplications = await models.Sequelize.CopilotApplication.findAll({
37-
where: {
38-
opportunityId: opportunity.id,
39-
id: {
40-
[Op.notIn]: [applicationId],
41-
}
42-
}
43-
});
35+
const sendEmailToAllApplicants = async (copilotRequest, allApplications) => {
4436

4537
const userIds = allApplications.map(item => item.userId);
4638

@@ -262,9 +254,6 @@ module.exports = [
262254

263255
await sendEmailToCopilot();
264256

265-
// Send email to all applicants about opportunity completion
266-
await sendEmailToAllApplicants(opportunity, copilotRequest, application.id);
267-
268257
// Cancel other applications
269258
const otherApplications = await models.CopilotApplication.findAll({
270259
where: {
@@ -276,6 +265,9 @@ module.exports = [
276265
transaction: t,
277266
});
278267

268+
// Send email to all applicants about opportunity completion
269+
await sendEmailToAllApplicants(copilotRequest, otherApplications);
270+
279271
for (const otherApplication of otherApplications) {
280272
await otherApplication.update({
281273
status: COPILOT_APPLICATION_STATUS.CANCELED,

0 commit comments

Comments
 (0)