I tried to add a lifecycle hook to send email notifications with the comments plugin.
All thread participants should receive an email notification whenever a user replies to a comment.
The lifecycle hook seems to be triggered only when a new comment is created but not when replying to comments.
Do you know how I can achieve that?
module.exports = ({ strapi }) => {
const commentsCommonService = strapi.plugin("comments").service("common");
commentsCommonService.registerLifecycleHook({
callback: async ({ action, result }) => {
console.log("Lifecycle hook called with:", action, result);
if (result.threadOf) {
console.log("Reply detected");
await strapi
.plugin("comments")
.service("client")
.sendResponseNotification(result);
}
},
contentTypeName: "comment",
hookName: "afterCreate",
});
};
This topic has been created from a Discord post (1265263991027138710) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord