mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
wip(shared): port sleep op
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user