Skip to content

Commit

Permalink
Stop sending mails on publish the post
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed May 3, 2024
1 parent 8926d18 commit 6cab607
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions admin/src/api/post/content-types/post/lifecycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ module.exports = {
},
});

const user = await strapi.entityService.findMany(
"plugin::users-permissions.user",
{
fields: "email",
filters: { is_subscribed: true },
}
);

for (i = 0; i < user.length; i++) {
const emailTemplatePath = path.join(
__dirname,
"../../../../../public/emailTemplates/subscribe.html"
);
const emailTemplate = handlebars.compile(
fs.readFileSync(emailTemplatePath, "utf8")
)({
postTitle: event.result.title,
summary: event.result.summary,
slug: event.result.slug,
imageUrl: event.result.image ? event.result.image.url : "",
userEmail: user[i].email,
});
let emailData = {
to: user[i].email,
from: process.env.HR_FROM_MAIL,
subject: event.result.title,
html: emailTemplate,
};
await strapi.plugins["email"].services.email.send(emailData);
}
// const user = await strapi.entityService.findMany(
// "plugin::users-permissions.user",
// {
// fields: "email",
// filters: { is_subscribed: true },
// }
// );

// for (i = 0; i < user.length; i++) {
// const emailTemplatePath = path.join(
// __dirname,
// "../../../../../public/emailTemplates/subscribe.html"
// );
// const emailTemplate = handlebars.compile(
// fs.readFileSync(emailTemplatePath, "utf8")
// )({
// postTitle: event.result.title,
// summary: event.result.summary,
// slug: event.result.slug,
// imageUrl: event.result.image ? event.result.image.url : "",
// userEmail: user[i].email,
// });
// let emailData = {
// to: user[i].email,
// from: process.env.HR_FROM_MAIL,
// subject: event.result.title,
// html: emailTemplate,
// };
// await strapi.plugins["email"].services.email.send(emailData);
// }
}
}
},
Expand Down

0 comments on commit 6cab607

Please sign in to comment.