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