correo corregido
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
const moment = require('moment');
|
||||
const dbHelper = '../../helper';
|
||||
const gmail = require(`${dbHelper}/gmail`);
|
||||
const { correoAsistencia } = require(`${dbHelper}/correos`);
|
||||
const { validarId } = require(`${dbHelper}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
@@ -10,7 +8,6 @@ const ahora = moment();
|
||||
|
||||
const pasarLista = async (body) => {
|
||||
const idAlumno = validarId(body.idAlumno);
|
||||
let correo = {};
|
||||
let horario = moment();
|
||||
|
||||
return Alumno.findOne({
|
||||
@@ -19,25 +16,17 @@ const pasarLista = async (body) => {
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este alumno.');
|
||||
horario = moment(res.Horario.horario);
|
||||
if (!res.idHorario)
|
||||
throw new Error('Este alumno no tiene ningún horario asignado.');
|
||||
if (res.asistio) throw new Error('Ya paso lista a este alumno.');
|
||||
horario = moment(res.Horario.horario);
|
||||
horario.add(-1, 'm');
|
||||
if (ahora <= horario) throw new Error('Aun no es la hora del recorrido.');
|
||||
horario.add(20, 'm');
|
||||
horario.add(22, 'm');
|
||||
if (ahora >= horario) throw new Error('Ya paso la hora del recorrido.');
|
||||
return Alumno.update({ asistio: true }, { where: { idAlumno } });
|
||||
})
|
||||
.then((res) => {
|
||||
correo = correoAsistencia();
|
||||
return gmail(
|
||||
correo.subject,
|
||||
'lemuelhelonmarquezrosas@gmail.com',
|
||||
correo.message
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
return { message: 'Se paso lista correctamente.' };
|
||||
});
|
||||
.then((res) => ({ message: 'Se paso lista correctamente.' }));
|
||||
};
|
||||
|
||||
module.exports = pasarLista;
|
||||
|
||||
Reference in New Issue
Block a user