mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
start upgrading eslint
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user