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 {SteamID | String} userID - ID of the user associated to this sharedfile
|
||||||
* @param {String} sharedFileId - ID of the sharedfile
|
* @param {String} sharedFileId - ID of the sharedfile
|
||||||
* @param {String} cid - ID of the comment to delete
|
* @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) {
|
SteamCommunity.prototype.deleteSharedFileComment = function(userID, sharedFileId, cid, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID == 'string') {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sharedFileId}/`,
|
await this.httpRequest({
|
||||||
"form": {
|
method: 'POST',
|
||||||
"gidcomment": cid,
|
url: `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sharedFileId}/`,
|
||||||
"count": 10,
|
form: {
|
||||||
"sessionid": this.getSessionID()
|
gidcomment: cid,
|
||||||
}
|
count: 10,
|
||||||
}, function(err, response, body) {
|
sessionid: this.getSessionID()
|
||||||
if (!callback) {
|
},
|
||||||
return;
|
source: 'steamcommunity'
|
||||||
}
|
});
|
||||||
|
|
||||||
callback(err);
|
resolve();
|
||||||
}, "steamcommunity");
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Favorites a sharedfile
|
* Favorites a sharedfile
|
||||||
* @param {String} sharedFileId - ID of the sharedfile
|
* @param {String} sharedFileId - ID of the sharedfile
|
||||||
* @param {String} appid - ID of the app associated to this 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) {
|
SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, callback) {
|
||||||
this.httpRequestPost({
|
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/favorite",
|
await this.httpRequest({
|
||||||
"form": {
|
method: 'POST',
|
||||||
"id": sharedFileId,
|
url: 'https://steamcommunity.com/sharedfiles/favorite',
|
||||||
"appid": appid,
|
form: {
|
||||||
"sessionid": this.getSessionID()
|
id: sharedFileId,
|
||||||
}
|
appid,
|
||||||
}, function(err, response, body) {
|
sessionid: this.getSessionID()
|
||||||
if (!callback) {
|
},
|
||||||
return;
|
source: 'steamcommunity'
|
||||||
}
|
});
|
||||||
|
|
||||||
callback(err);
|
resolve();
|
||||||
}, "steamcommunity");
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,76 +62,79 @@ SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, call
|
|||||||
* @param {SteamID | String} userID - ID of the user associated to this sharedfile
|
* @param {SteamID | String} userID - ID of the user associated to this sharedfile
|
||||||
* @param {String} sharedFileId - ID of the sharedfile
|
* @param {String} sharedFileId - ID of the sharedfile
|
||||||
* @param {String} message - Content of the comment to post
|
* @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) {
|
SteamCommunity.prototype.postSharedFileComment = function(userID, sharedFileId, message, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID == 'string') {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sharedFileId}/`,
|
await this.httpRequest({
|
||||||
"form": {
|
method: 'POST',
|
||||||
"comment": message,
|
url: `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sharedFileId}/`,
|
||||||
"count": 10,
|
form: {
|
||||||
"sessionid": this.getSessionID()
|
comment: message,
|
||||||
}
|
count: 10,
|
||||||
}, function(err, response, body) {
|
sessionid: this.getSessionID()
|
||||||
if (!callback) {
|
},
|
||||||
return;
|
source: 'steamcommunity'
|
||||||
}
|
});
|
||||||
|
|
||||||
callback(err);
|
resolve();
|
||||||
}, "steamcommunity");
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes to a sharedfile's comment section. Note: Checkbox on webpage does not update
|
* 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 {SteamID | String} userID ID of the user associated to this sharedfile
|
||||||
* @param {String} sharedFileId ID of the 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) {
|
SteamCommunity.prototype.subscribeSharedFileComments = function(userID, sharedFileId, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID == 'string') {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sharedFileId}/`,
|
await this.httpRequest({
|
||||||
"form": {
|
method: 'POST',
|
||||||
"count": 10,
|
url: `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sharedFileId}/`,
|
||||||
"sessionid": this.getSessionID()
|
form: {
|
||||||
}
|
count: 10,
|
||||||
}, function(err, response, body) { // eslint-disable-line
|
sessionid: this.getSessionID()
|
||||||
if (!callback) {
|
},
|
||||||
return;
|
source: 'steamcommunity'
|
||||||
}
|
});
|
||||||
|
|
||||||
callback(err);
|
resolve();
|
||||||
}, "steamcommunity");
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unfavorites a sharedfile
|
* Unfavorites a sharedfile
|
||||||
* @param {String} sharedFileId - ID of the sharedfile
|
* @param {String} sharedFileId - ID of the sharedfile
|
||||||
* @param {String} appid - ID of the app associated to this 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) {
|
SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, callback) {
|
||||||
this.httpRequestPost({
|
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||||
"uri": "https://steamcommunity.com/sharedfiles/unfavorite",
|
await this.httpRequest({
|
||||||
"form": {
|
method: 'POST',
|
||||||
"id": sharedFileId,
|
url: 'https://steamcommunity.com/sharedfiles/unfavorite',
|
||||||
"appid": appid,
|
form: {
|
||||||
"sessionid": this.getSessionID()
|
id: sharedFileId,
|
||||||
}
|
appid,
|
||||||
}, function(err, response, body) {
|
sessionid: this.getSessionID()
|
||||||
if (!callback) {
|
},
|
||||||
return;
|
source: 'steamcommunity'
|
||||||
}
|
});
|
||||||
|
|
||||||
callback(err);
|
resolve();
|
||||||
}, "steamcommunity");
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,21 +144,20 @@ SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, ca
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.unsubscribeSharedFileComments = function(userID, sharedFileId, callback) {
|
SteamCommunity.prototype.unsubscribeSharedFileComments = function(userID, sharedFileId, callback) {
|
||||||
if (typeof userID === "string") {
|
if (typeof userID === 'string') {
|
||||||
userID = new SteamID(userID);
|
userID = new SteamID(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
return StdLib.Promises.callbackPromise(null, callback, true, async (resolve, reject) => {
|
||||||
"uri": `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sharedFileId}/`,
|
await this.httpRequest({
|
||||||
"form": {
|
method: 'POST',
|
||||||
"count": 10,
|
url: `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sharedFileId}/`,
|
||||||
"sessionid": this.getSessionID()
|
form: {
|
||||||
}
|
count: 10,
|
||||||
}, function(err, response, body) { // eslint-disable-line
|
sessionid: this.getSessionID()
|
||||||
if (!callback) {
|
}
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
callback(err);
|
resolve();
|
||||||
}, "steamcommunity");
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user