Last active
December 30, 2021 09:44
-
-
Save Vitaleks-project/f67ee9a1e3b8349c959f2162a59b02a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Update user video settings | |
POST /user_settings/video_settings | |
body: { | |
enableDisclaimer: boolean, | |
enableWatermark: boolean | |
} | |
*/ | |
updateVideoSettings: function (req, res) { | |
const updateObj = {}; | |
if(!_.isUndefined(req.param('enableDisclaimer'))) updateObj.enableDisclaimer = req.param('enableDisclaimer'); | |
if(!_.isUndefined(req.param('enableWatermark'))) updateObj.enableWatermark = req.param('enableWatermark'); | |
return User.update(req.session.User.id, updateObj) | |
.then(users => { | |
if (!users || !users.length) { | |
return res.json(404, { status: 'failed', error: 'User not found' }); | |
} | |
var user = _.pick(users[0], ['id', 'name', 'email', 'enableDisclaimer', 'enableWatermark']); | |
req.session.User.enableDisclaimer = user.enableDisclaimer; | |
req.session.User.enableWatermark = user.enableWatermark; | |
return res.json({ status: 'SUCCESS', settings: user }); | |
}) | |
.catch(error => res.status(500).send({ status: 'failed', error })); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment