-
Notifications
You must be signed in to change notification settings - Fork 6
feat(discord): Update discord_activity_tracker app: per-channel incremental export #283
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
Merged
wpak-ai
merged 7 commits into
cppalliance:develop
from
leostar0412:feat/discord-token-extraction
Jun 12, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b2206f2
feat(discord): implement internal user token extraction and management
leostar0412 94e895a
feat(discord): enhance Discord export functionality with per-channel …
leostar0412 56c4f9c
refactor: clean up code formatting and improve readability in various…
leostar0412 5904a6e
feat(discord): add configuration for internal Discord token managemen…
leostar0412 113c7d2
fix(docs): update README and command output to clarify date handling …
leostar0412 16b0ac3
refactor(discord): update internal token management to use session cr…
leostar0412 0d4f67d
test(discord): add fallback mechanism for legacy Discord token retrie…
leostar0412 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
discord_activity_tracker/management/commands/extract_discord_tokens.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """ | ||
| Management command: extract_discord_tokens | ||
|
|
||
| Persist Discord session credentials to workspace JSON. | ||
| """ | ||
|
|
||
| import logging | ||
|
|
||
| from django.conf import settings | ||
| from django.core.management.base import BaseCommand, CommandError | ||
|
|
||
| from discord_activity_tracker.utils.discord_internal_tokens_store import ( | ||
| discord_internal_tokens_json_path, | ||
| extract_and_save_discord_internal_tokens, | ||
| ) | ||
| from discord_activity_tracker.utils.discord_tokens import ( | ||
| _resolve_discord_chrome_profile_root, | ||
| ) | ||
| from discord_activity_tracker.workspace import get_chrome_profile_path | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class Command(BaseCommand): | ||
| help = ( | ||
| "Persist Discord session credentials to " | ||
| "workspace/discord_activity_tracker/discord_internal_tokens.json." | ||
| ) | ||
|
|
||
| def handle(self, *args, **options): | ||
| allow_raw = getattr(settings, "ALLOW_INTERNAL_DISCORD_TOKENS", "") or "" | ||
| if isinstance(allow_raw, bool): | ||
| allow = allow_raw | ||
| else: | ||
| allow = str(allow_raw).strip().lower() == "true" | ||
| if not allow: | ||
| self.stderr.write( | ||
| self.style.WARNING( | ||
| "Internal Discord session mode is not enabled: credentials will be saved to " | ||
| "workspace JSON but ignored by Django until enabled. " | ||
| "Restart web/celery after enabling. See .env.example." | ||
| ) | ||
| ) | ||
|
|
||
| try: | ||
| profile = _resolve_discord_chrome_profile_root() | ||
| except ValueError as e: | ||
| raise CommandError(str(e)) from e | ||
| profile_path = str(profile) | ||
| if not profile.is_dir(): | ||
| raise CommandError( | ||
| "Session storage not found " | ||
| f"({profile_path}). Expected: {get_chrome_profile_path()}. " | ||
| "See .env.example." | ||
| ) | ||
|
|
||
| token = extract_and_save_discord_internal_tokens() | ||
| if not token: | ||
| raise CommandError("Failed to load session credentials. See .env.example.") | ||
| out_path = discord_internal_tokens_json_path() | ||
| self.stdout.write( | ||
| self.style.SUCCESS(f"Saved Discord session credentials to {out_path}.") | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.