start upgrading eslint

This commit is contained in:
Matteo Pagliazzi
2019-10-08 16:57:10 +02:00
parent 90c917f69e
commit 621787915c
304 changed files with 5992 additions and 6394 deletions

View File

@@ -5,7 +5,7 @@ import {
NotFound,
} from '../../libs/errors';
let api = {};
const api = {};
/**
* @api {get} /email/unsubscribe Unsubscribe an email or user from email notifications
@@ -27,28 +27,28 @@ api.unsubscribe = {
async handler (req, res) {
req.checkQuery({
code: {
notEmpty: {errorMessage: res.t('missingUnsubscriptionCode')},
notEmpty: { errorMessage: res.t('missingUnsubscriptionCode') },
},
});
let validationErrors = req.validationErrors();
const validationErrors = req.validationErrors();
if (validationErrors) throw validationErrors;
let data = JSON.parse(decrypt(req.query.code));
const data = JSON.parse(decrypt(req.query.code));
if (data._id) {
let userUpdated = await User.update(
{_id: data._id},
{ $set: {'preferences.emailNotifications.unsubscribeFromAll': true}}
const userUpdated = await User.update(
{ _id: data._id },
{ $set: { 'preferences.emailNotifications.unsubscribeFromAll': true } },
).exec();
if (userUpdated.nModified !== 1) throw new NotFound(res.t('userNotFound'));
res.send(`<h1>${res.t('unsubscribedSuccessfully')}</h1> ${res.t('unsubscribedTextUsers')}`);
} else {
let unsubscribedEmail = await EmailUnsubscription.findOne({email: data.email.toLowerCase()}).exec();
if (!unsubscribedEmail) await EmailUnsubscription.create({email: data.email.toLowerCase()});
const unsubscribedEmail = await EmailUnsubscription.findOne({ email: data.email.toLowerCase() }).exec();
if (!unsubscribedEmail) await EmailUnsubscription.create({ email: data.email.toLowerCase() });
let okResponse = `<h1>${res.t('unsubscribedSuccessfully')}</h1> ${res.t('unsubscribedTextOthers')}`;
const okResponse = `<h1>${res.t('unsubscribedSuccessfully')}</h1> ${res.t('unsubscribedTextOthers')}`;
res.send(okResponse);
}
},