mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
res.respond: allow for thrid parameter (message), refactor shared ops responses and adapt tests
This commit is contained in:
@@ -33,14 +33,12 @@ module.exports = function sell (user, req = {}) {
|
||||
user.items[type][key]--;
|
||||
user.stats.gp += content[type][key].value;
|
||||
|
||||
let response = {
|
||||
data: _.pick(user, splitWhitespace('stats items')),
|
||||
message: i18n.t('sold', {type, key}),
|
||||
};
|
||||
|
||||
if (req.v2 === true) {
|
||||
return response.data;
|
||||
return _.pick(user, splitWhitespace('stats items'));
|
||||
} else {
|
||||
return response;
|
||||
return [
|
||||
_.pick(user, splitWhitespace('stats items')),
|
||||
i18n.t('sold', {type, key}),
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user