mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
check pinning for unknow item type and path (#9087)
This commit is contained in:
@@ -68,6 +68,7 @@
|
|||||||
"wishlist": "Wishlist",
|
"wishlist": "Wishlist",
|
||||||
"items": "Items",
|
"items": "Items",
|
||||||
"wrongItemType": "The item type \"<%= type %>\" is not valid.",
|
"wrongItemType": "The item type \"<%= type %>\" is not valid.",
|
||||||
|
"wrongItemPath": "The item path \"<%= path %>\" is not valid.",
|
||||||
"unpinnedItem": "You unpinned <%= item %>! It will no longer display in your Rewards column.",
|
"unpinnedItem": "You unpinned <%= item %>! It will no longer display in your Rewards column.",
|
||||||
"cannotUnpinArmoirPotion": "The Health Potion and Enchanted Armoire cannot be unpinned.",
|
"cannotUnpinArmoirPotion": "The Health Potion and Enchanted Armoire cannot be unpinned.",
|
||||||
"purchasedItem": "You bought <%= itemName %>",
|
"purchasedItem": "You bought <%= itemName %>",
|
||||||
|
|||||||
@@ -122,11 +122,24 @@ function removePinnedItemsByOwnedGear (user) {
|
|||||||
function togglePinnedItem (user, {item, type, path}, req = {}) {
|
function togglePinnedItem (user, {item, type, path}, req = {}) {
|
||||||
let arrayToChange;
|
let arrayToChange;
|
||||||
|
|
||||||
if (!path) { // If path isn't passed it means an item was passed
|
if (!path) {
|
||||||
|
// If path isn't passed it means an item was passed
|
||||||
path = getItemInfo(user, type, item, req.language).path;
|
path = getItemInfo(user, type, item, req.language).path;
|
||||||
|
} else {
|
||||||
|
if (!item) {
|
||||||
|
item = get(content, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!item) {
|
||||||
|
// path not exists in our content structure
|
||||||
|
|
||||||
|
throw new BadRequest(i18n.t('wrongItemPath', {path}, req.language));
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if item exists & valid to be pinned
|
||||||
|
getItemInfo(user, type, item, req.language);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item) item = get(content, path);
|
|
||||||
|
|
||||||
if (path === 'armoire' || path === 'potion') {
|
if (path === 'armoire' || path === 'potion') {
|
||||||
throw new BadRequest(i18n.t('cannotUnpinArmoirPotion', req.language));
|
throw new BadRequest(i18n.t('cannotUnpinArmoirPotion', req.language));
|
||||||
|
|||||||
Reference in New Issue
Block a user