mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
feat: Add modify inventory debug menu
This commit is contained in:
@@ -101,4 +101,44 @@ api.setCron = {
|
||||
// },
|
||||
// };
|
||||
|
||||
/**
|
||||
* @api {post} /api/v3/debug/modify-inventory Manipulate user's inventory
|
||||
* @apiDescription Only available in development mode.
|
||||
* @apiVersion 3.0.0
|
||||
* @apiName modifyInventory
|
||||
* @apiGroup Development
|
||||
*
|
||||
* @apiSuccess {Object} data An empty Object
|
||||
*/
|
||||
api.modifyInventory = {
|
||||
method: 'POST',
|
||||
url: '/debug/modify-inventory',
|
||||
middlewares: [ensureDevelpmentMode, authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let { gear } = req.body;
|
||||
|
||||
if (gear) {
|
||||
user.items.gear.owned = gear;
|
||||
}
|
||||
|
||||
[
|
||||
'special',
|
||||
'pets',
|
||||
'mounts',
|
||||
'eggs',
|
||||
'hatchingPotions',
|
||||
'food',
|
||||
'quests',
|
||||
].forEach((type) => {
|
||||
if (req.body[type]) {
|
||||
user.items[type] = req.body[type];
|
||||
}
|
||||
});
|
||||
|
||||
await user.save();
|
||||
|
||||
res.respond(200, {});
|
||||
},
|
||||
};
|
||||
module.exports = api;
|
||||
|
||||
Reference in New Issue
Block a user