a
This commit is contained in:
parent
a4b814747e
commit
2d09aae5dc
@ -8,6 +8,22 @@ const Sequelize = require('sequelize');
|
|||||||
|
|
||||||
const extraMethods = {
|
const extraMethods = {
|
||||||
|
|
||||||
|
_getUserByEmail: async (email) => {
|
||||||
|
return models.User.findOne({
|
||||||
|
where: {
|
||||||
|
email: email,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
_getUserById: async (Id) => {
|
||||||
|
return models.User.findOne({
|
||||||
|
where: {
|
||||||
|
id: Id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
_getOrCreateUser: async (dataUser) => {
|
_getOrCreateUser: async (dataUser) => {
|
||||||
|
|
||||||
let result = null;
|
let result = null;
|
||||||
@ -35,16 +51,6 @@ const extraMethods = {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
_getUserByEmail: async (email) => {
|
|
||||||
return models.User.findOne({
|
|
||||||
where: {
|
|
||||||
email: email,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = generateService(models.User, extraMethods);
|
module.exports = generateService(models.User, extraMethods);
|
||||||
@ -536,49 +536,49 @@ console.log(headerMail, bodyMail);
|
|||||||
sendMailTicket: async (req, res, next) => {
|
sendMailTicket: async (req, res, next) => {
|
||||||
const params = extractParamsFromRequest(req, res, {});
|
const params = extractParamsFromRequest(req, res, {});
|
||||||
const inscriptionId = params.params.id;
|
const inscriptionId = params.params.id;
|
||||||
const userId = req.user.id;
|
const user = req.user;
|
||||||
try {
|
try {
|
||||||
const inscription = await eventInscriptionService._getInscriptionById(inscriptionId);
|
const inscription = await eventInscriptionService._getInscriptionById(inscriptionId);
|
||||||
if (!inscription) //{
|
if (!inscription)
|
||||||
return handleResultResponse("Inscription no encontrada", null, params, res, httpStatus.NOT_FOUND);
|
return handleResultResponse("Inscription no encontrada", null, params, res, httpStatus.NOT_FOUND);
|
||||||
// } else if (inscription.userId !== userId) {
|
|
||||||
// return handleResultResponse("Inscription no encontrada", null, params, res, httpStatus.NOT_FOUND);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
// if (inscription.userId !== user.id)
|
||||||
|
// return handleResultResponse("Inscription no encontrada", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
|
||||||
|
const userInscription = await userService._getUserById(inscription.userId);
|
||||||
|
|
||||||
|
console.log(inscription);
|
||||||
const qrConfig = {
|
const qrConfig = {
|
||||||
name: req.user.name,
|
name: userInscription.name,
|
||||||
surname: req.user.surname,
|
surname: userInscription.surname,
|
||||||
date: inscription.date,
|
date: inscription.date,
|
||||||
code: inscription.code_ticket,
|
code: inscription.code_ticket,
|
||||||
color: (inscription.reservation) ? inscription.reservation.color : null,
|
color: (inscription.reservation) ? inscription.reservation.color : null,
|
||||||
}
|
}
|
||||||
const qrCode = await QRHelper.getInscriptionQRCode(qrConfig);
|
const qrCode = await QRHelper.getInscriptionQRCode(qrConfig);
|
||||||
|
|
||||||
console.log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<', req.user);
|
|
||||||
var headerMail = {
|
var headerMail = {
|
||||||
to: req.user.email,
|
to: userInscription.email,
|
||||||
name: req.user.name + ' ' + req.user.surname,
|
name: userInscription.name + ' ' + userInscription.surname,
|
||||||
// subject: ((member.validated) ? 'Entrada' : 'Lista de espera') + ' para el congreso ' + dataInscription.event.name + ' confirmada'
|
subject: ((inscription.validated) ? 'Entrada' : 'Lista de espera') + ' para el congreso ' + inscription.event.name + ' confirmada'
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
var bodyMail = {
|
var bodyMail = {
|
||||||
tipoEntrada: (member.validated) ? 'Entrada' : 'Lista de espera',
|
tipoEntrada: (inscription.validated) ? 'Entrada' : 'Lista de espera',
|
||||||
descriptionEntrada: member.description,
|
descriptionEntrada: (inscription.reservation) ? inscription.reservation.description : 'Entrada Normal',
|
||||||
qrCode: qrCode,
|
qrCode: qrCode,
|
||||||
color: qrConfig.color,
|
color: qrConfig.color,
|
||||||
codeTicket: member.code_ticket,
|
codeTicket: inscription.code_ticket,
|
||||||
eventName: dataInscription.event.name,
|
eventName: inscription.event.name,
|
||||||
dateInscription: moment(dataInscription.event.init_date).format('D [de] MMMM [de] YYYY'),
|
dateInscription: moment(inscription.event.init_date).format('D [de] MMMM [de] YYYY'),
|
||||||
}
|
}
|
||||||
console.log('Mandamos mail con entrada>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
console.log('Mandamos mail con entrada>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
||||||
console.log(headerMail, bodyMail);
|
console.log(headerMail, bodyMail);
|
||||||
if (member.validated)
|
if (inscription.validated)
|
||||||
emailHelper.sendTicket(headerMail, bodyMail)
|
emailHelper.sendTicket(headerMail, bodyMail)
|
||||||
else
|
else
|
||||||
emailHelper.sendListaEspera(headerMail, bodyMail);
|
emailHelper.sendListaEspera(headerMail, bodyMail);
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
return handleResultResponse(null, null, params, res, httpStatus.OK);
|
return handleResultResponse(null, null, params, res, httpStatus.OK);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -163,6 +163,12 @@ routes.get('/me/inscriptions',
|
|||||||
eventController.getInscriptions,
|
eventController.getInscriptions,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
routes.get('/me/inscriptions/:id/mail',
|
||||||
|
isLoggedUser,
|
||||||
|
//cacheSuccesses('1 hour'),
|
||||||
|
eventController.sendMailTicket,
|
||||||
|
);
|
||||||
|
|
||||||
// Esto da la inscripción de un usuario
|
// Esto da la inscripción de un usuario
|
||||||
routes.get('/me/inscriptions/:id',
|
routes.get('/me/inscriptions/:id',
|
||||||
isLoggedUser,
|
isLoggedUser,
|
||||||
@ -174,16 +180,6 @@ routes.get('/me/inscriptions/:id',
|
|||||||
eventController.getInscription,
|
eventController.getInscription,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Inscription QR Code
|
|
||||||
//routes.get('/me/inscriptions/:id/qr', isLoggedUser,
|
|
||||||
//cacheSuccesses('1 hour'),
|
|
||||||
// eventController.getQRCodeInscription,
|
|
||||||
//);
|
|
||||||
routes.get('/me/inscriptions/:id/mail',
|
|
||||||
isLoggedUser,
|
|
||||||
//cacheSuccesses('1 hour'),
|
|
||||||
eventController.sendMailTicket,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/*router.get('/:conferenceId/inscription/:userId/qrimage', function (req, res) {
|
/*router.get('/:conferenceId/inscription/:userId/qrimage', function (req, res) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user