Send email to user after publishing teks
This commit is contained in:
@@ -20,3 +20,5 @@ SMTP_PASSWORD=
|
|||||||
SMTP_FROM=
|
SMTP_FROM=
|
||||||
SMTP_REPLY_TO=
|
SMTP_REPLY_TO=
|
||||||
SMTP_SEND_TO=
|
SMTP_SEND_TO=
|
||||||
|
|
||||||
|
WEBSITE_URL=http://localhost:3000
|
||||||
|
|||||||
@@ -20,6 +20,24 @@ module.exports = {
|
|||||||
const awtis = await jwennAwtisEpiId(data.awtis)
|
const awtis = await jwennAwtisEpiId(data.awtis)
|
||||||
data.slug = slugify(`${awtis}-${data.tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
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 => {
|
afterCreate: async data => {
|
||||||
if (data.user) {
|
if (data.user) {
|
||||||
|
|||||||
Reference in New Issue
Block a user