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

Add user/workshop/curator follow & unfollow support #320

Merged
merged 5 commits into from
Oct 2, 2023

Conversation

3urobeat
Copy link
Contributor

Hey, it's me again.
This PR adds support for following and unfollowing a user.

Following a user from their profile dropdown or from the user's "Workshop Items" page does the same thing, that's why I mentioned both in the title.

 

Documentation for the CSteamUser wiki page:

### follow([callback])
- `callback` - Optional.
    - `err` - `null` on success, an `Error` object on failure

**Non-object method name: `followUser`**

**v3.x.x or later is required to use this method.**

Follows the user and their workshop.

### unfollow([callback])
- `callback` - Optional.
    - `err` - `null` on success, an `Error` object on failure

**Non-object method name: `unfollowUser`**

**v3.x.x or later is required to use this method.**

Unfollows the user and their workshop.

Don't forget to fill out the version number should you copy and paste this.

 

That's it, I hope the amount of PRs by me don't get on your nerves too much (warning: there is probably one more coming soon because I want to add support for reviews).
Have a nice day :)

@3urobeat
Copy link
Contributor Author

3urobeat commented Sep 25, 2023

I have also added support for following & unfollowing curators; it uses a different endpoint.

I added the two functions to groups.js as curator pages are made from groups and are tied to another - I hope this makes sense; I did not want to create a separate file for two methods.
I did not add object methods to CSteamGroup.js as the clanid param used in this request is different from the gid or any other group related id.
Please let me know if I should rather create a new file for the two methods.

Documentation for the SteamCommunity wiki page:

### followCurator(clanid, [callback])
- `clanid` - ID of the curator, is displayed in the URL
- `callback` - Optional.
    - `err` - `null` on success, an `Error` object on failure

**v3.x.x or later is required to use this method.**

Follows a curator page.  
Note: Requires an unlimited account.

### unfollowCurator(clanid, [callback])
- `clanid` - ID of the curator, is displayed in the URL
- `callback` - Optional.
    - `err` - `null` on success, an `Error` object on failure

**v3.x.x or later is required to use this method.**

Unfollows a curator page.  
Note: Requires an unlimited account.

Don't forget to fill out the version number should you copy and paste this.

To quickly test this, call the function with the clanid 1850 to follow the well-known PC-Gamer curator page.

@3urobeat 3urobeat changed the title Add user/workshop follow & unfollow support Add user/workshop/curator follow & unfollow support Sep 25, 2023
@Revadike
Copy link
Contributor

You prob want to merge it into #230

@3urobeat
Copy link
Contributor Author

Yeah I thought about that but ultimately decided against it as DoctorMcKay merged my previous PRs into v4 afterwards anyway and the v4 branch seems a bit stale.
I can open another PR/rebase this one though if you wish

@3urobeat 3urobeat changed the base branch from master to v4 October 1, 2023 17:03
return;
}

if (body.success) {
Copy link
Owner

Choose a reason for hiding this comment

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

Is body.success a number? If so, it might be an eresult rather than boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, this should be an eresult. I'll fix this real quick

@3urobeat
Copy link
Contributor Author

3urobeat commented Oct 1, 2023

Should be correct like this.
Steam returns for users: { success: 1 }
...and for curators: { success: { success: 1, nSaleTaskCompleted: null } }

Comment on lines 758 to 760
if (body.success && body.success.success != SteamCommunity.EResult.OK) {
let err = new Error(body.message || SteamCommunity.EResult[body.success.success]);
err.eresult = err.code = body.success.success;
Copy link
Owner

Choose a reason for hiding this comment

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

Helpers.eresultError does all this for you.

@DoctorMcKay DoctorMcKay changed the base branch from v4 to master October 1, 2023 20:00
@DoctorMcKay
Copy link
Owner

DoctorMcKay commented Oct 1, 2023

Let's target this at master.

@3urobeat
Copy link
Contributor Author

3urobeat commented Oct 1, 2023

Like this? There are quite a few functions which do not use the eresultError() helper...

@DoctorMcKay
Copy link
Owner

Yeah, looks good. I'll merge & deploy this later tonight, once I can get some docs written.

There are quite a few functions which do not use the eresultError() helper

Those predate the helper, most likely.

@DoctorMcKay DoctorMcKay merged commit bf2b460 into DoctorMcKay:master Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants