habitica-self-host/common/script/ops/addWebhook.js

16 lines
416 B
JavaScript
Raw Normal View History

2016-03-07 22:02:42 +00:00
import refPush from '../libs/refPush';
module.exports = function(user, req, cb) {
var wh;
wh = user.preferences.webhooks;
2016-03-08 16:49:18 +00:00
refPush(wh, {
2016-03-07 22:02:42 +00:00
url: req.body.url,
enabled: req.body.enabled || true,
id: req.body.id
});
if (typeof user.markModified === "function") {
user.markModified('preferences.webhooks');
}
return typeof cb === "function" ? cb(null, user.preferences.webhooks) : void 0;
};