wip(shared): port sleep op

This commit is contained in:
Matteo Pagliazzi
2016-03-15 16:33:44 +01:00
parent f55df39fb7
commit 490c6a9ae1
7 changed files with 50 additions and 6 deletions

View File

@@ -13,6 +13,8 @@ import Q from 'q';
import _ from 'lodash';
import * as passwordUtils from '../../libs/api-v3/password';
const sleep = common.ops.sleep;
let api = {};
/**
@@ -277,4 +279,27 @@ api.castSpell = {
},
};
/**
* @api {post} /user/sleep Put the user in the inn.
* @apiVersion 3.0.0
* @apiName UserSleep
* @apiGroup User
*
* @apiSuccess {Object} Will return an object with the new `user.preferences.sleep` value. Example `{preferences: {sleep: true}}`
*/
api.sleep = {
method: 'POST',
middlewares: [authWithHeaders(), cron],
url: '/user/sleep',
async handler (req, res) {
let user = res.locals.user;
let sleepVal = sleep(user);
return res.respond(200, {
preferences: {
sleep: sleepVal,
},
});
},
};
module.exports = api;