Send email to user after publishing teks
This commit is contained in:
@@ -20,6 +20,24 @@ module.exports = {
|
||||
const awtis = await jwennAwtisEpiId(data.awtis)
|
||||
data.slug = slugify(`${awtis}-${data.tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
||||
}
|
||||
if (data.published_at != null) {
|
||||
const {_id} = params
|
||||
const previousData = await strapi.query('teks').findOne({_id})
|
||||
|
||||
const previousPublishedAt = previousData.published_at
|
||||
const currentPublished_at = data.published_at
|
||||
if (currentPublished_at != previousPublishedAt) {
|
||||
if (previousData.user) {
|
||||
strapi.services.email.send(
|
||||
process.env.SMTP_FROM,
|
||||
previousData.user.email,
|
||||
`Publication de "${previousData.tit}"`,
|
||||
`Le titre que vous avez soumis, "${previousData.tit}" a été publié sur le site.
|
||||
Vous pouvez le trouver à l'adresse ${process.env.WEBSITE_URL}/teks/${previousData.slug}`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
afterCreate: async data => {
|
||||
if (data.user) {
|
||||
|
||||
Reference in New Issue
Block a user