mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
Ported open mystery item, added unit tests, added route, and integration tests
This commit is contained in:
@@ -676,4 +676,24 @@ api.disableClasses = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {post} /user/open-mystery-item Open the mystery item.
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName UserOpenMysteryItem
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiSuccess {Object} data `user.items.gear.owned`
|
||||
*/
|
||||
api.userOpenMysteryItem = {
|
||||
method: 'POST',
|
||||
middlewares: [authWithHeaders(), cron],
|
||||
url: '/user/open-mystery-item',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let openMysteryItemResponse = common.ops.openMysteryItem(user, req, res.analytics);
|
||||
await user.save();
|
||||
res.respond(200, openMysteryItemResponse);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
|
||||
Reference in New Issue
Block a user