email checking
This commit is contained in:
parent
1919323521
commit
acddc25918
@ -40,22 +40,49 @@ exports.createConfig = async (req, res) => {
|
|||||||
support_email: process.env.SUPPORT_EMAIL,
|
support_email: process.env.SUPPORT_EMAIL,
|
||||||
support_phone: process.env.SUPPORT_PHONE
|
support_phone: process.env.SUPPORT_PHONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const EstablishmentUserData = await EstablishmentUser.findAll({where: { is_active: 1 }});
|
const EstablishmentUserData = await EstablishmentUser.findAll({where: { is_active: 1 }});
|
||||||
const establishmentEmailPromises = EstablishmentUserData.map((userObj) => {
|
const establishmentEmailPromises = EstablishmentUserData.map(async (userObj) => {
|
||||||
return sendEmailService(userObj.email,"quarterly_survey_created_to_establishment", placeholder);
|
try {
|
||||||
});
|
await sendEmailService(
|
||||||
|
userObj.email,
|
||||||
await Promise.all([
|
"quarterly_survey_created_to_establishment",
|
||||||
...establishmentEmailPromises
|
placeholder
|
||||||
]);
|
);
|
||||||
|
return { email: userObj.email, status: "sent" };
|
||||||
const data = await QuarterlyWindowsConfiguration.create(req.body);
|
} catch (error) {
|
||||||
res.status(201).send({
|
return { email: userObj.email, status: "failed", error: error.message };
|
||||||
status: "success",
|
}
|
||||||
message: "Quarterly window configuration created successfully",
|
|
||||||
data,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Wait for all emails to resolve
|
||||||
|
const emailResults = await Promise.all(establishmentEmailPromises);
|
||||||
|
|
||||||
|
// Create quarterly window configuration
|
||||||
|
const data = await QuarterlyWindowsConfiguration.create(req.body);
|
||||||
|
|
||||||
|
res.status(201).send({
|
||||||
|
status: "success",
|
||||||
|
message: "Quarterly window configuration created successfully",
|
||||||
|
data,
|
||||||
|
emailResults,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const establishmentEmailPromises = EstablishmentUserData.map((userObj) => {
|
||||||
|
// return sendEmailService(userObj.email,"quarterly_survey_created_to_establishment", placeholder);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// await Promise.all([
|
||||||
|
// ...establishmentEmailPromises
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// const data = await QuarterlyWindowsConfiguration.create(req.body);
|
||||||
|
// res.status(201).send({
|
||||||
|
// status: "success",
|
||||||
|
// message: "Quarterly window configuration created successfully",
|
||||||
|
// data,
|
||||||
|
// });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(500).send({ status: "failed", message: err.message });
|
res.status(500).send({ status: "failed", message: err.message });
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user