mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
res.respond: allow for thrid parameter (message), refactor shared ops responses and adapt tests
This commit is contained in:
@@ -7,8 +7,7 @@ import {
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = function addWebhook (user, req = {}) {
|
||||
let wh;
|
||||
wh = user.preferences.webhooks;
|
||||
let wh = user.preferences.webhooks;
|
||||
|
||||
if (!validator.isURL(_.get(req, 'body.url'))) throw new BadRequest(i18n.t('invalidUrl', req.language));
|
||||
if (!validator.isBoolean(_.get(req, 'body.enabled'))) throw new BadRequest(i18n.t('invalidEnabled', req.language));
|
||||
@@ -18,9 +17,11 @@ module.exports = function addWebhook (user, req = {}) {
|
||||
if (req.v2 === true) {
|
||||
return user.preferences.webhooks;
|
||||
} else {
|
||||
return refPush(wh, {
|
||||
url: req.body.url,
|
||||
enabled: req.body.enabled,
|
||||
});
|
||||
return [
|
||||
refPush(wh, {
|
||||
url: req.body.url,
|
||||
enabled: req.body.enabled,
|
||||
}),
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user