mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-14 15:00:07 +08:00
Add user/workshop/curator follow & unfollow support (#320)
* Add follow & unfollow user functions * Add follow & unfollow to CSteamUser object methods * Add support for following & unfollowing curators * Correctly parse for eresult on error * Use eresultError() helper
This commit is contained in:
parent
f69519f547
commit
bf2b4601ee
@ -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);
|
||||
};
|
||||
|
@ -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");
|
||||
};
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user