solving problem with chat emails

parent 83edc34f
...@@ -42,10 +42,10 @@ module.exports = { ...@@ -42,10 +42,10 @@ module.exports = {
return ([Promise.resolve(msg), StuSup.find({id_stu: params.id_stu}).populate('supervisor')]); return ([Promise.resolve(msg), StuSup.find({id_stu: params.id_stu}).populate('supervisor')]);
}) })
.spread((msg, stusups) => { .spread((msg, stusups) => {
var emails = ""; var emails = [];
for (var i=0; i<stusups.length; i++) { for (var i=0; i<stusups.length; i++) {
if (stusups[i].supervisor.id !== params.id_sup) if (stusups[i].supervisor.id !== params.id_sup)
emails = emails + " " + stusups[i].supervisor.email; emails.append(stusups[i].supervisor.email);
} }
// Email body // Email body
...@@ -68,10 +68,12 @@ module.exports = { ...@@ -68,10 +68,12 @@ module.exports = {
locale: msg.supervisor.lang || 'es-es' locale: msg.supervisor.lang || 'es-es'
}); });
sails.log.debug("Sending chat notification on student " + msg.student.id + " to " + emails.join());
// Send Emails // Send Emails
mailService.mailer() mailService.mailer()
.send({ .send({
to: emails, to: emails.join(),
text: message, text: message,
subject: subject subject: subject
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment