email notification on message submission working

parent ddf9d638
......@@ -39,14 +39,15 @@ module.exports = {
.then((msg) => {
// Send sockets notification
sails.sockets.broadcast('studentRoom' + params.id_stu, 'chatmessage', msg.toJSON(), req.socket);
return StuSup.find({id_stu: params.id_stu, id_sup: params.id_sup}).populate('supervisor');
return ([Promise.resolve(msg), StuSup.find({id_stu: params.id_stu}).populate('supervisor')]);
})
.then((stusups) => {
.spread((msg, stusups) => {
var emails = "";
for (var i=0; i<stusups.length; i++) {
if (stusups[i].supervisor.id != params.id_sup)
emails += " " + stusups[i].supervisor.email;
if (stusups[i].supervisor.id !== params.id_sup)
emails = emails + " " + stusups[i].supervisor.email;
}
// Email body
var message = sails.__(
{
......@@ -54,10 +55,10 @@ module.exports = {
locale: msg.supervisor.lang
},
{
stuName: msg.student.name,
stuSurname: msg.student.surname,
supName: msg.supervisor.name,
supSurname: msg.supervisor.surname,
stuname: msg.student.name,
stusurname: msg.student.surname,
supname: msg.supervisor.name,
supsurname: msg.supervisor.role == 'office' ? "" : msg.supervisor.surname,
content: msg.content
});
......@@ -78,11 +79,10 @@ module.exports = {
.catch((err) => {});
// Ready, we respond with an Ok!
return res.ok(obj);
return res.ok(msg);
})
.catch((err) => {
console.log("Error adding new message: " + err);
return res.serverError('Message not saved');
});
}
......
......@@ -500,6 +500,7 @@
"type_your_message_here": "Type your message here",
"unlink": "Unlink",
"up": "Up",
"unable_to_send_message": "Unable to send message",
"undefined": "Undefined",
"unlimited": "Unlimited",
"update_office": "Update office",
......
......@@ -496,6 +496,7 @@
"tutor_not_found": "No hay ningún tutor en Pictogram con ese correo electrónico",
"tutors": "Tutores",
"type_your_message_here": "Escriba el mensaje aquí",
"unable_to_send_message": "No se ha podido enviar el mensaje",
"undefined": "Sin definir",
"unlink": "Desvincular",
"unlimited": "Ilimitada",
......
......@@ -49,7 +49,7 @@ dashboardControllers.controller('StudentChatCtrl', function StudentInstructionsC
$scope.$apply();
}
else
console.log("Error from API: " + resData);
ngToast.danger($translate.instant('unable_to_send_message'));
});
};
......
......@@ -593,9 +593,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
grid: data
}, function () {});
$translate('grid_added').then(function (translation) {
ngToast.success({ content: translation });
});
ngToast.success($translate.instant('grid_added'));
$scope.loadGridsList();
......
......@@ -4,8 +4,7 @@
"license_annual": "Pictogram 12-months License",
"license_pro": "Pictogram PRO license",
"login": "login",
"new_chat_message": "A new message was sent by {{ supName }} {{ supSurname }} about the student {{ stuName }} {{ stuSurname }}:\n
\" {{ content }} \"\n\n -- Pictogram chat service notification",
"new_chat_message": "A new message was sent by {{{ supName }}} {{{ supSurname }}} about the student {{{ stuName }}} {{{ stuSurname }}}:\n>>>\n{{{ content }}}\n<<<\n\n -- Pictogram chat service notification",
"notification_from_pictogram": "Notification from Pictogram",
"no_name": "No name",
"no_surname": "No surname",
......
......@@ -4,8 +4,7 @@
"license_annual": "Pictogram licencia 12 meses",
"license_pro": "Pictogram licencia PRO",
"login": "acceder",
"new_chat_message": "Un nuevo mensaje ha sido enviado por {{ supName }} {{ supSurname }} acerca del estudiante {{ stuName }} {{ stuSurname }}:\n
\" {{ content }} \"\n\n -- Notificación del servicio de chat de Pictogram",
"new_chat_message": "Un nuevo mensaje ha sido enviado por {{{ supname }}} {{{ supsurname }}} acerca del estudiante {{{ stuname }}} {{{ stusurname }}}:\n>>>\n{{{ content }}}\n<<<\n\n -- Notificación del servicio de chat de Pictogram",
"notification_from_pictogram": "Notificación desde Pictogram",
"no_name": "Sin nombre",
"no_surname": "Sin apellidos",
......
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