-
-
Notifications
You must be signed in to change notification settings - Fork 487
Restore User.moderator_subreddits #1764
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
Restore User.moderator_subreddits #1764
Conversation
|
This seems like an edge case where the replacement method has issues fetching such a large list. I have personally tested it with AutoModerator in the past without issues other than a slight delay with the request, however this isn't working anymore. I don't know what changed (if anything) with the endpoint. Would you be able to request the old endpoint for these edge cases? |
If you're asking about using the old endpoint on AutoModerator, then no. Sorry if this was confusing. The "new" endpoint, used by While I was writing the pull request, I also discovered that I just tried |
86f7343 to
da7fe29
Compare
|
That is really strange that it would behave differently in read-only mode. Also, I just realized I misread this PR. I thought you were replacing the underling endpoint with the old one. Does |
LilSpazJoekp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of things. Let's move the doc changes to contributor_subreddits and subreddits to a new PR please.
From the error messages I got, I would guess that that the request fails in logged-in mode because they have to check if the account has access to each individual subreddit. In read-only mode, it knows that only public subreddits are viewable, so the request is processed faster.
|
da7fe29 to
2d1f611
Compare
The methods `User.contributor_subreddits` and `User.subreddits` need to use either an explicit limit or a limit of None in order to retrieve more than 100 subreddits.
LilSpazJoekp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'll get this merged in!
|
🎇 Thanks for this! Would you mind joining the slack when you get a chance? We would like to talk to you a couple of things.🙂 |
Unfixes 1333
Feature Summary and Justification
Issue 1142 reported that
User.moderator_subredditswould not return more than 100 subreddits, and this information was added to the documentation in 1145. The method was deprecated in 1148, with a note to useRedditor.moderatedinstead, and was removed in 1333.I suspect that the report of the alleged limitation of
User.moderator_subredditswas not correct, and may have just been the result of a misunderstanding of howListingGeneratorworks. I tested the sister method ofUser.moderator_subreddits,User.subreddits, and found that it also returns only 100 subreddits if you calllist(reddit.user.subreddits()). But that happens becauseListingGenerators default value forlimitis 100. If you calllist(reddit.user.subreddits(limit=None)), the ListingGenerator does yield all of the subreddits that you are subscribed to, by retrieving batches of 100 subreddits at a time. From what I can find on Github, it's not clear if anyone tested what happens when you callmoderator_subredditswith limit set toNonebefore the method was removed. The subreddits/mine/where endpoints are documented under the same heading, so it's reasonable to think that they would all share the same limitations. I don't see anything in the initial commit or the last released version that suggests any kind of endpoint-specific limit.Even if there were a limit of 100 subreddits returned,
moderatedis not an adequate replacement formoderator_subredditsfor the vast majority of users.Moderator_subredditsloads the data that you would get by callingReddit.infowithsr_namesset to the names of the subs you moderate, andmoderatorreturns a much smaller amount of data. You would need to make additional calls toinfo, or filter calls tocontributor_subredditsto get the same information, which is not very convenient.Moderator_subredditsalso has the advantage of returning the user subreddit, which is not something thatmoderateddoes.Moderator_subreddits, which returns a listing, may actually be more robust than moderated, which returns aModeratedList. In certain circumstances, calls tomoderatedmay fail altogether, because all of the subreddits are returned at once. For example, request_bot moderates almost 20,000 subreddits. When I tried to usemoderatedwith a user-mode token, I got 5xx errors. With a userless token, I was served 12MB and 1MB responses when I set "accept-encoding" to identity and gzip/deflate respectively. There may be a cap to the number of subreddits returned by subreddits/mine/moderator, but since it returns batches of up to 100 results at a time, you should at least be able to retrieve the top n subreddits before a hypothetical cutoff.References