mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2026-08-19 13:13:28 +08:00
Updated sharedfiles.js methods to use new http interface
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
var SteamID = require('steamid');
|
||||
const StdLib = require('@doctormckay/stdlib');
|
||||
const SteamID = require('steamid');
|
||||
|
||||
var SteamCommunity = require('../index.js');
|
||||
const SteamCommunity = require('../index.js');
|
||||
|
||||
|
||||
/**
|
||||
@@ -8,50 +9,52 @@ var SteamCommunity = require('../index.js');
|
||||
* @param {SteamID | String} userID - ID of the user associated to this sharedfile
|
||||
* @param {String} sharedFileId - ID of the sharedfile
|
||||
* @param {String} cid - ID of the comment to delete
|
||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||
* @param {function} [callback] - Takes only an Error object/null as the first argument
|
||||
* @return Promise<void>
|
||||
*/
|
||||
SteamCommunity.prototype.deleteSharedFileComment = function(userID, sharedFileId, cid, callback) {
|
||||
if (typeof userID === "string") {
|
||||
if (typeof userID == 'string') {
|
||||
userID = new SteamID(userID);
|
||||
}
|
||||
|
||||
this.httpRequestPost({
|
||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sharedFileId}/`,
|
||||
"form": {
|
||||
"gidcomment": cid,
|
||||
"count": 10,
|
||||
"sessionid": this.getSessionID()
|
||||
}
|
||||
}, function(err, response, body) {
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||
await this.httpRequest({
|
||||
method: 'POST',
|
||||
url: `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sharedFileId}/`,
|
||||
form: {
|
||||
gidcomment: cid,
|
||||
count: 10,
|
||||
sessionid: this.getSessionID()
|
||||
},
|
||||
source: 'steamcommunity'
|
||||
});
|
||||
|
||||
callback(err);
|
||||
}, "steamcommunity");
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Favorites a sharedfile
|
||||
* @param {String} sharedFileId - ID of the sharedfile
|
||||
* @param {String} appid - ID of the app associated to this sharedfile
|
||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||
* @param {function} [callback] - Takes only an Error object/null as the first argument
|
||||
* @return Promise<void>
|
||||
*/
|
||||
SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, callback) {
|
||||
this.httpRequestPost({
|
||||
"uri": "https://steamcommunity.com/sharedfiles/favorite",
|
||||
"form": {
|
||||
"id": sharedFileId,
|
||||
"appid": appid,
|
||||
"sessionid": this.getSessionID()
|
||||
}
|
||||
}, function(err, response, body) {
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||
await this.httpRequest({
|
||||
method: 'POST',
|
||||
url: 'https://steamcommunity.com/sharedfiles/favorite',
|
||||
form: {
|
||||
id: sharedFileId,
|
||||
appid,
|
||||
sessionid: this.getSessionID()
|
||||
},
|
||||
source: 'steamcommunity'
|
||||
});
|
||||
|
||||
callback(err);
|
||||
}, "steamcommunity");
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -59,76 +62,79 @@ SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, call
|
||||
* @param {SteamID | String} userID - ID of the user associated to this sharedfile
|
||||
* @param {String} sharedFileId - ID of the sharedfile
|
||||
* @param {String} message - Content of the comment to post
|
||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||
* @param {function} [callback] - Takes only an Error object/null as the first argument
|
||||
* @return Promise<void>
|
||||
*/
|
||||
SteamCommunity.prototype.postSharedFileComment = function(userID, sharedFileId, message, callback) {
|
||||
if (typeof userID === "string") {
|
||||
if (typeof userID == 'string') {
|
||||
userID = new SteamID(userID);
|
||||
}
|
||||
|
||||
this.httpRequestPost({
|
||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sharedFileId}/`,
|
||||
"form": {
|
||||
"comment": message,
|
||||
"count": 10,
|
||||
"sessionid": this.getSessionID()
|
||||
}
|
||||
}, function(err, response, body) {
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||
await this.httpRequest({
|
||||
method: 'POST',
|
||||
url: `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sharedFileId}/`,
|
||||
form: {
|
||||
comment: message,
|
||||
count: 10,
|
||||
sessionid: this.getSessionID()
|
||||
},
|
||||
source: 'steamcommunity'
|
||||
});
|
||||
|
||||
callback(err);
|
||||
}, "steamcommunity");
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Subscribes to a sharedfile's comment section. Note: Checkbox on webpage does not update
|
||||
* @param {SteamID | String} userID ID of the user associated to this sharedfile
|
||||
* @param {String} sharedFileId ID of the sharedfile
|
||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||
* @param {function} [callback] - Takes only an Error object/null as the first argument
|
||||
* @return Promise<void>
|
||||
*/
|
||||
SteamCommunity.prototype.subscribeSharedFileComments = function(userID, sharedFileId, callback) {
|
||||
if (typeof userID === "string") {
|
||||
if (typeof userID == 'string') {
|
||||
userID = new SteamID(userID);
|
||||
}
|
||||
|
||||
this.httpRequestPost({
|
||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sharedFileId}/`,
|
||||
"form": {
|
||||
"count": 10,
|
||||
"sessionid": this.getSessionID()
|
||||
}
|
||||
}, function(err, response, body) { // eslint-disable-line
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||
await this.httpRequest({
|
||||
method: 'POST',
|
||||
url: `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sharedFileId}/`,
|
||||
form: {
|
||||
count: 10,
|
||||
sessionid: this.getSessionID()
|
||||
},
|
||||
source: 'steamcommunity'
|
||||
});
|
||||
|
||||
callback(err);
|
||||
}, "steamcommunity");
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Unfavorites a sharedfile
|
||||
* @param {String} sharedFileId - ID of the sharedfile
|
||||
* @param {String} appid - ID of the app associated to this sharedfile
|
||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||
* @param {function} [callback] - Takes only an Error object/null as the first argument
|
||||
* @return Promise<void>
|
||||
*/
|
||||
SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, callback) {
|
||||
this.httpRequestPost({
|
||||
"uri": "https://steamcommunity.com/sharedfiles/unfavorite",
|
||||
"form": {
|
||||
"id": sharedFileId,
|
||||
"appid": appid,
|
||||
"sessionid": this.getSessionID()
|
||||
}
|
||||
}, function(err, response, body) {
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||
await this.httpRequest({
|
||||
method: 'POST',
|
||||
url: 'https://steamcommunity.com/sharedfiles/unfavorite',
|
||||
form: {
|
||||
id: sharedFileId,
|
||||
appid,
|
||||
sessionid: this.getSessionID()
|
||||
},
|
||||
source: 'steamcommunity'
|
||||
});
|
||||
|
||||
callback(err);
|
||||
}, "steamcommunity");
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -138,21 +144,20 @@ SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, ca
|
||||
* @param {function} callback - Takes only an Error object/null as the first argument
|
||||
*/
|
||||
SteamCommunity.prototype.unsubscribeSharedFileComments = function(userID, sharedFileId, callback) {
|
||||
if (typeof userID === "string") {
|
||||
if (typeof userID === 'string') {
|
||||
userID = new SteamID(userID);
|
||||
}
|
||||
|
||||
this.httpRequestPost({
|
||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sharedFileId}/`,
|
||||
"form": {
|
||||
"count": 10,
|
||||
"sessionid": this.getSessionID()
|
||||
}
|
||||
}, function(err, response, body) { // eslint-disable-line
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||
await this.httpRequest({
|
||||
method: 'POST',
|
||||
url: `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sharedFileId}/`,
|
||||
form: {
|
||||
count: 10,
|
||||
sessionid: this.getSessionID()
|
||||
}
|
||||
});
|
||||
|
||||
callback(err);
|
||||
}, "steamcommunity");
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user