mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-02-06 23:34:44 +08:00
Fixed getUserInventoryContexts not properly returning errors for private inventory/profile
Closes #305
This commit is contained in:
parent
29e18806cc
commit
f69519f547
@ -385,18 +385,7 @@ SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) {
|
||||
|
||||
var match = body.match(/var g_rgAppContextData = ([^\n]+);\r?\n/);
|
||||
if (!match) {
|
||||
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));
|
||||
callback(new Error('Malformed response'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -408,6 +397,21 @@ SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Object.keys(data).length == 0) {
|
||||
if (body.match(/inventory is currently private\./)) {
|
||||
callback(new Error('Private inventory'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (body.match(/profile_private_info/)) {
|
||||
callback(new Error('Private profile'));
|
||||
return;
|
||||
}
|
||||
|
||||
// If they truly have no items in their inventory, Steam will send g_rgAppContextData as [] instead of {}.
|
||||
data = {};
|
||||
}
|
||||
|
||||
callback(null, data);
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user