Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sharedfiles scraping error when Steam returns non-English page, fix rejected request detection and improve type detection #316

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 61 additions & 11 deletions components/sharedfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@ SteamCommunity.prototype.deleteSharedFileComment = function(userID, sharedFileId
"form": {
"gidcomment": cid,
"count": 10,
"json": 1,
"sessionid": this.getSessionID()
}
},
"json": true
}, function(err, response, body) {
if (!callback) {
return;
}

callback(err);
if (err) {
callback(err);
return;
}

if (body.success) {
callback(null);
} else {
callback(new Error(body.error));
}
Comment on lines +39 to +43
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this tested and confirmed working? Typically, when Steam returns a success key, it's an eresult and not a bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, Steam returns the following here: { success: false, error: 'There was a problem deleting this comment. Please try again.' }

}, "steamcommunity");
};

Expand All @@ -45,7 +56,7 @@ SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, call
"appid": appid,
"sessionid": this.getSessionID()
}
}, function(err, response, body) {
}, function(err, response, body) { // Steam does not seem to return any errors for this request
if (!callback) {
return;
}
Expand All @@ -71,14 +82,25 @@ SteamCommunity.prototype.postSharedFileComment = function(userID, sharedFileId,
"form": {
"comment": message,
"count": 10,
"json": 1,
"sessionid": this.getSessionID()
}
},
"json": true
}, function(err, response, body) {
if (!callback) {
return;
}

callback(err);
if (err) {
callback(err);
return;
}

if (body.success) {
callback(null);
} else {
callback(new Error(body.error));
}
Comment on lines +101 to +105
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tested; Steam returns the following: { success: false, error: 'There was a problem posting your comment. Please try again.' }

}, "steamcommunity");
};

Expand All @@ -97,14 +119,28 @@ SteamCommunity.prototype.subscribeSharedFileComments = function(userID, sharedFi
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sharedFileId}/`,
"form": {
"count": 10,
"json": 1,
"sessionid": this.getSessionID()
}
},
"json": true
}, function(err, response, body) { // eslint-disable-line
if (!callback) {
return;
}

callback(err);
if (err) {
callback(err);
return;
}

if (body.success && body.success != SteamCommunity.EResult.OK) {
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
err.eresult = err.code = body.success;
callback(err);
return;
}

callback(null);
}, "steamcommunity");
};

Expand All @@ -122,7 +158,7 @@ SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, ca
"appid": appid,
"sessionid": this.getSessionID()
}
}, function(err, response, body) {
}, function(err, response, body) { // Steam does not seem to return any errors for this request
if (!callback) {
return;
}
Expand All @@ -146,13 +182,27 @@ SteamCommunity.prototype.unsubscribeSharedFileComments = function(userID, shared
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sharedFileId}/`,
"form": {
"count": 10,
"json": 1,
"sessionid": this.getSessionID()
}
},
"json": true
}, function(err, response, body) { // eslint-disable-line
if (!callback) {
return;
}

callback(err);
if (err) {
callback(err);
return;
}

if (body.success && body.success != SteamCommunity.EResult.OK) {
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
err.eresult = err.code = body.success;
callback(err);
return;
}

callback(null);
}, "steamcommunity");
};
};