Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-09-23 15:08:43 +02:00
commit 53386e3974
1 changed files with 4 additions and 8 deletions

View File

@ -1,5 +1,4 @@
const Imap = require('imap');
const {NULL} = require('node-sass');
module.exports = Self => {
Self.remoteMethod('checkInbox', {
description: 'Check an email inbox and process it',
@ -91,7 +90,6 @@ module.exports = Self => {
};
async function emailConfirm(buffer) {
console.log('buffer', buffer);
const now = new Date();
const from = JSON.stringify(Imap.parseHeader(buffer).from);
const subject = JSON.stringify(Imap.parseHeader(buffer).subject);
@ -102,7 +100,7 @@ module.exports = Self => {
const user = await getUser(from);
let workerMail;
if (user.id != NULL) {
if (user.id != null) {
workerMail = await Self.app.models.WorkerTimeControlMail.findOne({
where: {
week: week,
@ -111,7 +109,7 @@ module.exports = Self => {
}
});
}
if (workerMail != NULL) {
if (workerMail != null) {
await workerMail.updateAttributes({
updated: now,
state: 'CONFIRMED'
@ -120,8 +118,6 @@ module.exports = Self => {
}
async function emailReply(buffer, emailBody) {
console.log('buffer', buffer);
console.log('emailBody', emailBody);
const now = new Date();
const from = JSON.stringify(Imap.parseHeader(buffer).from);
const subject = JSON.stringify(Imap.parseHeader(buffer).subject);
@ -132,7 +128,7 @@ module.exports = Self => {
const user = await getUser(from);
let workerMail;
if (user.id != NULL) {
if (user.id != null) {
workerMail = await Self.app.models.WorkerTimeControlMail.findOne({
where: {
week: week,
@ -141,7 +137,7 @@ module.exports = Self => {
}
});
if (workerMail != NULL) {
if (workerMail != null) {
await workerMail.updateAttributes({
updated: now,
state: 'REVISE',