Skip to content

Commit

Permalink
Merge pull request #159 from canopas/pause-sending-mail-on-publish-post
Browse files Browse the repository at this point in the history
Stop sending mails on publish the post
  • Loading branch information
cp-dharti-r authored May 3, 2024
2 parents 8926d18 + 6cab607 commit 89e0059
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 89e0059

Please sign in to comment.