Fix creating commentaires
This commit is contained in:
@@ -12,7 +12,7 @@ const jwennUserEpiId = async userId => {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
beforeCreate: async event => {
|
beforeCreate: async event => {
|
||||||
let {data} = event
|
let {data} = event.params
|
||||||
|
|
||||||
if (data.contenu && data.parole && data.user) {
|
if (data.contenu && data.parole && data.user) {
|
||||||
const parole = await jwennTeksEpiId(data.parole)
|
const parole = await jwennTeksEpiId(data.parole)
|
||||||
@@ -26,12 +26,15 @@ module.exports = {
|
|||||||
throw new ValidationError('Mauvaise requête')
|
throw new ValidationError('Mauvaise requête')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
afterCreate: async data => {
|
afterCreate: async event => {
|
||||||
if (data.user) {
|
const {data} = event.params
|
||||||
|
const user = await jwennUserEpiId(data.user)
|
||||||
|
|
||||||
|
if (user) {
|
||||||
strapi.plugins['email'].services.email.send({
|
strapi.plugins['email'].services.email.send({
|
||||||
from: process.env.SMTP_FROM,
|
from: process.env.SMTP_FROM,
|
||||||
to: process.env.SMTP_SEND_TO,
|
to: process.env.SMTP_SEND_TO,
|
||||||
subject: `Nouveau commentaire de ${data.user.username}`,
|
subject: `Nouveau commentaire de ${user.username}`,
|
||||||
html: data.contenu
|
html: data.contenu
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user