diff --git a/classes/CSteamUser.js b/classes/CSteamUser.js index f019b77..8b26516 100644 --- a/classes/CSteamUser.js +++ b/classes/CSteamUser.js @@ -166,6 +166,14 @@ CSteamUser.prototype.inviteToGroup = function(groupID, callback) { this._community.inviteUserToGroup(this.steamID, groupID, callback); }; +CSteamUser.prototype.follow = function(callback) { + this._community.followUser(this.steamID, callback); +}; + +CSteamUser.prototype.unfollow = function(callback) { + this._community.unfollowUser(this.steamID, callback); +}; + CSteamUser.prototype.getAliases = function(callback) { this._community.getUserAliases(this.steamID, callback); }; diff --git a/components/groups.js b/components/groups.js index 9f74f50..5ed64f6 100644 --- a/components/groups.js +++ b/components/groups.js @@ -730,3 +730,69 @@ SteamCommunity.prototype.respondToAllGroupJoinRequests = function(gid, approve, } }, "steamcommunity"); }; + +/** + * Follows a curator page + * @param {string} clanid - ID of the curator + * @param {function} callback - Takes only an Error object/null as the first argument + */ +SteamCommunity.prototype.followCurator = function(clanid, callback) { + this.httpRequestPost({ + "uri": "https://store.steampowered.com/curators/ajaxfollow", + "form": { + "clanid": clanid, + "sessionid": this.getSessionID(), + "follow": 1 + }, + "json": true + }, (err, res, body) => { + if (!callback) { + return; + } + + if (err) { + callback(err); + return; + } + + if (body.success && body.success.success != SteamCommunity.EResult.OK) { + callback(Helpers.eresultError(body.success.success)); + return; + } + + callback(null); + }, "steamcommunity"); +}; + +/** + * Unfollows a curator page + * @param {string} clanid - ID of the curator + * @param {function} callback - Takes only an Error object/null as the first argument + */ +SteamCommunity.prototype.unfollowCurator = function(clanid, callback) { + this.httpRequestPost({ + "uri": "https://store.steampowered.com/curators/ajaxfollow", + "form": { + "clanid": clanid, + "sessionid": this.getSessionID(), + "follow": 0 + }, + "json": true + }, (err, res, body) => { + if (!callback) { + return; + } + + if (err) { + callback(err); + return; + } + + if (body.success && body.success.success != SteamCommunity.EResult.OK) { + callback(Helpers.eresultError(body.success.success)); + return; + } + + callback(null); + }, "steamcommunity"); +}; \ No newline at end of file diff --git a/components/users.js b/components/users.js index df8a90f..48a1d8e 100644 --- a/components/users.js +++ b/components/users.js @@ -296,6 +296,66 @@ SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback) }, "steamcommunity"); }; +SteamCommunity.prototype.followUser = function(userID, callback) { + if(typeof userID === 'string') { + userID = new SteamID(userID); + } + + this.httpRequestPost({ + "uri": `https://steamcommunity.com/profiles/${userID.toString()}/followuser/`, + "form": { + "sessionid": this.getSessionID(), + }, + "json": true + }, function(err, response, body) { + if (!callback) { + return; + } + + if (err) { + callback(err); + return; + } + + if (body.success && body.success != SteamCommunity.EResult.OK) { + callback(Helpers.eresultError(body.success)); + return; + } + + callback(null); + }, "steamcommunity"); +}; + +SteamCommunity.prototype.unfollowUser = function(userID, callback) { + if(typeof userID === 'string') { + userID = new SteamID(userID); + } + + this.httpRequestPost({ + "uri": `https://steamcommunity.com/profiles/${userID.toString()}/unfollowuser/`, + "form": { + "sessionid": this.getSessionID(), + }, + "json": true + }, function(err, response, body) { + if (!callback) { + return; + } + + if (err) { + callback(err); + return; + } + + if (body.success && body.success != SteamCommunity.EResult.OK) { + callback(Helpers.eresultError(body.success)); + return; + } + + callback(null); + }, "steamcommunity"); +}; + SteamCommunity.prototype.getUserAliases = function(userID, callback) { if (typeof userID === 'string') { userID = new SteamID(userID);