Scope Analysis: Reddit-Backed Discussion Removal
Django Apps to Remove
1. channels/ - Primary Discussion App
Purpose: Manages channels (subreddits), posts, comments, subscriptions Location: ./channels/
Key Components:
- Models (
models.py, 390 lines):RedditRefreshToken- OAuth tokens for RedditRedditAccessToken- Access tokensSubscription- User subscriptions to posts/commentsChannel- Discussion channels (subreddit mirror)ChannelInvitation- Invites to private channelsLinkMeta- Embedly thumbnails for linksPost- Discussion postsArticle- Article-type postsComment- Comments on postsChannelSubscription- Channel subscriptionsChannelGroupRole- Moderator/contributor rolesChannelMembershipConfig- Channel membership settingsSpamCheckResult- Akismet spam check results
- API (
api.py, 1795 lines):- Reddit API integration (praw library)
- Channel CRUD operations
- Post CRUD operations
- Comment CRUD operations
- Voting functionality
- Moderation actions
- Subscription management
- Role management (moderators, contributors)
- Tasks (
tasks.py, 627 lines):update_discussion_models- Sync from Redditupdate_discussion_channels- Update channel datasend_subscription_email- Email notificationsupdate_discussion_posts- Update post datapopulate_post_subscription_memberships- Subscription synccheck_comments_for_spam- Spam checkingcheck_posts_for_spam- Spam checking- Multiple indexing tasks for search
- Views (
views/):channels.py- Channel list/detailposts.py- Post list/detailcomments.py- Comment list/detail/morecontributors.py- Contributor managementmoderators.py- Moderator managementsubscribers.py- Subscriber managementinvites.py- Channel invitationsfrontpage.py- Frontpage feedreports.py- Content reporting
- Serializers (
serializers/):channels.py- Channel serializationposts.py- Post serializationcomments.py- Comment serializationinvites.py- Invitation serialization
- Utilities:
utils.py- Reddit slugify, markdown renderingproxies.py- Proxy objects for Reddit dataspam.py- Akismet integrationbackpopulate_api.py- Data backpopulationmembership_api.py- Membership management
- Factories (
factories/):reddit.py- Reddit test factoriesmodels.py- Model factories for testing
2. discussions/ - Alternative Discussion Implementation
Purpose: Non-Reddit discussion implementation (newer) Location: ./discussions/
Key Components:
- Models (
models.py):Channel- Alternative channel model- Related models for non-Reddit discussions
- API (
api/):- Alternative discussion API
Note: This appears to be a newer implementation. Verify if it’s in use before removing.
3. channels_fields/ - Discussion Field Management
Purpose: Custom field management for channels Location: ./channels_fields/
Key Components:
- Field group and role management
- Serializers for custom fields
- Permissions for field management
Frontend Components to Remove
Location: ./frontends/open-discussions/src/
1. Pages (pages/):
ChannelAboutPage.js- Channel about pageChannelRouter.js- Channel routingPostDetailSidebar.js- Post detail sidebarHomePage.js- Frontpage (may need modification, not full removal)admin/CreateChannelPage.js- Channel creationadmin/EditChannelBasicPage.js- Basic channel settingsadmin/EditChannelAppearancePage.js- Channel appearanceadmin/EditChannelContributorsPage.js- Contributor managementadmin/EditChannelModeratorsPage.js- Moderator managementadmin/EditChannelMembershipPage.js- Membership settingsadmin/ChannelModerationPage.js- Moderation interface
2. Components (components/):
ChannelHeader.js- Channel headerChannelBanner.js- Channel bannerChannelAvatar.js- Channel avatarChannelNavbar.js- Channel navigationComment.js- Comment displayCommentForm.js- Comment formCommentTree.js- Comment treeCommentVoteForm.js- Comment votingCommentReportDialog.js- Report commentsCommentRemovalForm.js- Remove commentsCreatePostForm.js- Create postEditPostForm.js- Edit postCompactPostDisplay.js- Compact post viewExpandedPostDisplay.js- Full post viewPostList.js- Post listPostUpvoteButton.js- Post votingwidgets/ChannelWidgetList.js- Channel widgetsadmin/CreateChannelForm.js- Create channel formadmin/EditChannelBasicForm.js- Edit channel formadmin/EditChannelAppearanceForm.js- Appearance formadmin/EditChannelMembersForm.js- Members formadmin/EditChannelNavbar.js- Channel admin nav
3. State Management (actions/, reducers/):
actions/channel.js- Channel actionsactions/post.js- Post actionsactions/comment.js- Comment actionsactions/posts_for_channel.js- Channel postsreducers/channels.js- Channel statereducers/posts.js- Post statereducers/comments.js- Comment statereducers/posts_for_channel.js- Channel posts statereducers/channel_avatar.js- Channel avatar statereducers/channel_contributors.js- Contributors statereducers/channel_invitations.js- Invitations statereducers/channel_subscribers.js- Subscribers statereducers/post_removed.js- Removed post statereducers/related_posts.js- Related posts statereducers/user_contributions.js- User posts/comments
4. API Layer (lib/api/):
channels.js- Channel API callsposts.js- Post API callscomments.js- Comment API callsfrontpage.js- Frontpage APImoderation.js- Moderation APIembedly.js- Embedly integration (for link previews)
5. Factories (factories/):
channels.js- Channel test dataposts.js- Post test datacomments.js- Comment test dataembedly.js- Embedly test data
6. Type Definitions (flow/):
discussionTypes.js- Flow types for discussions
7. Utilities (lib/, util/):
lib/reddit_objects.js- Reddit object utilities- Any markdown or comment rendering utilities specific to discussions
Dependencies in Other Apps
Search App (search/)
Preserves: Podcast and course search Removes: Post and comment search
Files to Modify:
constants.py:- Keep:
PODCAST_TYPE,PODCAST_EPISODE_TYPE,COURSE_TYPE,PROGRAM_TYPE, etc. - Remove:
POST_TYPE,COMMENT_TYPEimports fromchannels.constants - Remove:
CONTENT_OBJECT_TYPEmapping - Keep:
PODCAST_OBJECT_TYPE,COURSE_OBJECT_TYPE, etc.
- Keep:
serializers.py:- Remove:
OSPostSerializer,OSCommentSerializer - Remove: Imports from
channels.models - Keep:
OSPodcastSerializer,OSPodcastEpisodeSerializer, course serializers
- Remove:
search_index_helpers.py:- Remove:
serialize_post_for_bulk,serialize_comment_for_bulk - Remove:
gen_post_id,gen_comment_id - Remove: Reddit object indexing
- Keep: Podcast and course indexing
- Remove:
api.py:- Remove: Channel-based search filtering
- Keep: General search API
tasks.py:- Remove: Post/comment indexing tasks
- Keep: Podcast/course indexing tasks
Notifications App (notifications/)
Files to Modify:
notifiers/comments.py:- REMOVE ENTIRE FILE - Comment notifications
- Remove imports from
channels
Mail App (mail/)
Files to Modify:
- Remove discussion-related email templates
- Remove subscription email logic
- Keep: General notification emails
Profiles App (profiles/)
Files to Modify:
views.py:- Remove: Post and comment display in profiles
- Remove imports from
channels.models - Keep: User profile display
api.py:- Remove: Channel role queries
- Keep: General profile API
URL Patterns to Remove
Django URLs (open_discussions/urls.py, channels/urls.py):
# Remove these patterns:
- r"^c/(?P<channel_name>...)" - All channel routes
- r"^manage/c/..." - Channel management routes
- r"^create_post/" - Post creation
- r"^channel/" - Channel redirect
- All patterns in channels.urls
- All patterns in channels_fields.urls
Frontend Routes (Router.js, App.js):
// Remove routes for:
- /c/:channel_name - Channel pages
- /c/:channel_name/:post_id/:slug - Post detail
- /create_post - Post creation
- /manage/c/... - Channel management
Database Tables to Remove
From channels app:
channels_redditrefreshtokenchannels_redditaccesstokenchannels_subscriptionchannels_channelchannels_channelinvitationchannels_linkmetachannels_postchannels_articlechannels_commentchannels_channelsubscriptionchannels_channelgrouprolechannels_channelmembershipconfigchannels_spamcheckresult
From discussions app:
- Verify current usage before listing
From channels_fields app:
- All custom field tables
Configuration to Remove
Environment Variables (.env, settings):
OPEN_DISCUSSIONS_REDDIT_URL- Reddit instance URLOPEN_DISCUSSIONS_REDDIT_CLIENT_ID- Reddit OAuth clientOPEN_DISCUSSIONS_REDDIT_SECRET- Reddit OAuth secretAKISMET_API_KEY- Spam checking (if only used for discussions)AKISMET_BLOG_URL- Spam checking
Django Settings (open_discussions/settings.py):
- Remove from
INSTALLED_APPS:'channels''channels_fields''discussions'(verify usage first)
- Remove middleware:
'open_discussions.middleware.channel_api.ChannelApiMiddleware'
- Remove Celery beat schedules:
- Discussion update tasks
- Spam check tasks
- Subscription email tasks
Python Dependencies (pyproject.toml, poetry.lock):
praw- Reddit API wrapperprawcore- Reddit API coreakismet- Spam detection (if only used for discussions)base36- Reddit ID encoding
External Service Dependencies to Remove
- Reddit Instance - No longer needed
- Akismet - If only used for discussion spam
- Embedly - If only used for post link previews (verify usage in other areas)
Search Index Cleanup
OpenSearch/Elasticsearch:
- Remove indices or documents for:
POST_TYPEdocumentsCOMMENT_TYPEdocuments
- Keep indices for:
PODCAST_TYPEPODCAST_EPISODE_TYPECOURSE_TYPEPROGRAM_TYPEVIDEO_TYPEPROFILE_TYPE- User lists
Testing Artifacts to Remove
- All test files in
channels/app - All test files in
discussions/app - All test files in
channels_fields/app - Frontend test files for removed components
- Cassettes (betamax recordings) for Reddit API calls
Files Count Summary
Backend (Python):
channels/app: ~50 filesdiscussions/app: ~10 fileschannels_fields/app: ~15 files- Modifications in other apps: ~20 files
Frontend (JavaScript/TypeScript):
- Components: ~40 files
- Pages: ~15 files
- Actions/Reducers: ~20 files
- API layer: ~8 files
- Factories/Tests: ~30 files
Total Estimated Files: ~200+ files to remove or modify
Next Steps
Proceed to 02-frontend-removal.md for detailed frontend removal instructions.