From 6d9ebabb1747d933619e9b0b5b4ed95b78de555a Mon Sep 17 00:00:00 2001 From: Unsigno Date: Tue, 11 Jul 2017 14:02:01 +0200 Subject: [PATCH] Updated getUserInventoryContexts to return 0 inventories and handle private profile error --- components/users.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/users.js b/components/users.js index 18b8e86..b65a9eb 100644 --- a/components/users.js +++ b/components/users.js @@ -241,7 +241,18 @@ SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) { var match = body.match(/var g_rgAppContextData = ([^\n]+);\r?\n/); if (!match) { - callback(new Error(body.match(/inventory is currently private\./) ? "Private inventory" : "Malformed response")); + var errorMessage = "Malformed response"; + + if(body.match(/0 items in their inventory\./)){ + callback(null, {}); + return; + }else if(body.match(/inventory is currently private\./)){ + errorMessage = "Private inventory"; + }else if(body.match(/profile\_private\_info/)){ + errorMessage = "Private profile"; + } + + callback(new Error(errorMessage)); return; }