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_phone: process.env.SUPPORT_PHONE
|
||||
};
|
||||
|
||||
const EstablishmentUserData = await EstablishmentUser.findAll({where: { is_active: 1 }});
|
||||
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,
|
||||
const establishmentEmailPromises = EstablishmentUserData.map(async (userObj) => {
|
||||
try {
|
||||
await sendEmailService(
|
||||
userObj.email,
|
||||
"quarterly_survey_created_to_establishment",
|
||||
placeholder
|
||||
);
|
||||
return { email: userObj.email, status: "sent" };
|
||||
} catch (error) {
|
||||
return { email: userObj.email, status: "failed", error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
// 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) {
|
||||
res.status(500).send({ status: "failed", message: err.message });
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user