Bug #657 mandar una notificacion al comercial de un cliente falla

This commit is contained in:
gerard 2018-09-14 08:08:38 +02:00
parent 0f14bf9d27
commit 3fafadf5c8
1 changed files with 3 additions and 1 deletions

View File

@ -69,6 +69,8 @@ module.exports = function(Self) {
let ctx = {req: {accessToken: accessToken}};
let insurance = await Self.findById(data.id, filter);
let customer = insurance.classification().customer();
if (!customer.salesPerson()) return;
let salesPerson = customer.salesPerson().user().name;
let grade = data.grade ? `(Grado ${data.grade})` : '(Sin grado)';
let message = {
@ -78,7 +80,7 @@ module.exports = function(Self) {
Self.app.models.Message.send(salesPerson, message, ctx);
};
// Update from transaction misses ctx accessToken.
// Update from transaction misses ctx accessToken.
// Fixed passing accessToken from method messageSend()
Self.observe('after save', async function(ctx) {
if (ctx.options.accessToken)