Skip to content

Commit

Permalink
solución al envío de mail al administrador
Browse files Browse the repository at this point in the history
  • Loading branch information
mpvaldez committed Apr 10, 2024
1 parent 50ce22a commit baf43ed
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions api/controllers/document-published.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,30 @@ exports.post = async (req, res) => {
.toArray()
log(`Document has ${tagsData.length} tags: "${tagsData.map(t=>t.name).join('", "')}"`)


// Notificamos a la cuenta de administrador del sistema
try {

notification.sendEmail('document-published', {
user: {
email: '[email protected]',
name: "Admin"
},
document: {
id: documentObj._id,
title: currentVersionObj.content.title,
author: documentObj.authorObj.fullname || documentObj.authorObj.username
},
matchingTags: []
})

} catch (err) {

log(`Error when sending mail to admin:`)
log(err)

}

// Buscamos todxs lxs usuarixs suscriptos a 1 o más de las etiquetas
const users = await db.collection('users')
.find({$and: [
Expand Down Expand Up @@ -123,6 +147,7 @@ exports.post = async (req, res) => {
})

// Devolvemos OK
const result = await db.collection('documents').updateOne({ _id: ObjectID(documentId) }, { $set: { publishedMailSent: true } })
log(`${emailsSent} email(s) scheduled`)
res.status(OK).json({
message: `${emailsSent} email(s) scheduled`
Expand Down

0 comments on commit baf43ed

Please sign in to comment.