-
Notifications
You must be signed in to change notification settings - Fork 2
Default Channels
Nathan Levesque edited this page Aug 23, 2018
·
2 revisions
Note: this document uses the terminology "subreddit" the should be considered synonymous with "channel".
In the Reddit backend, there are a few complexities of how default subreddits are configured and managed.
- This calls
Subreddit.user_subreddits()
, which does one of two things:- If the user is signed in and has subscriptions (e.g. has at one point explicitly added a subscript or removed a default one)
- The following lists are concatenated in order, up to a limit (default is 50 subreddits):
-
Subreddit.subscribed_ids_by_user(user)
- the list of subreddits a user is subscribed to -
g.automatic_reddits
- a configuration variable for the automatic reddits a user is subscribed to on signup.- Note: This configuration variable is only used for the frontpage. These subreddits show up nowhere else, so this config value is only useful in ensuring the user never sees an empty frontpage even if they unsubscribe from everything.
-
- The following lists are concatenated in order, up to a limit (default is 50 subreddits):
- Otherwise (e.g. anonymous user, user with no subscription modifications):
- The default subreddits (
Subreddit.default_subreddits()
) are used (this may be empty)
- The default subreddits (
- If the user is signed in and has subscriptions (e.g. has at one point explicitly added a subscript or removed a default one)
- These values are stored in Cassandra and cached in memcache. They can apparently be localized, but for simplicity we're only going to worry about the "Global" locale
- They are retrieved by
LocalizedDefaultSubreddits.get_global_defaults()
- They are set by
LocalizedDefaultSubreddits.set_global_srs(<list of Subreddit>)
- Assuming a new or anonymous user, default subreddits don't show up in the user's subscribed subreddits (
GET /subreddits/mine/subscriber
), even though they are treated as such in the Reddit UI- Thus, you need to call the Reddit API
GET /subreddits/default
to get the list of default channels outside of reddit - However, the default channels still contribute to the frontpage
- This means that from an API perspective, you can't tell the difference between these two scenarios:
- A new user with no subscription changes
- An existing user who has unsubscribed from all default channels
- So for a signed in user, we can't intelligently and safely determine if we should append the default channels to their list of channels
- Thus, you need to call the Reddit API