Updated getUserInventoryContexts to return 0 inventories and handle private profile error

This commit is contained in:
Unsigno 2017-07-11 14:02:01 +02:00
parent 5d5d8548af
commit 6d9ebabb17

View File

@ -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;
}