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

Prefer message timestamp over the last-modified header for asset file dates #1321

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

ritiek
Copy link
Contributor

@ritiek ritiek commented Dec 1, 2024

Fixes #1320.

With this PR, date-modified timestamp for attachments now prefers the timestamp of the message in which the attachment was originally shared on Discord:

Performing export of the same channel as originally shared in #1320:

$ DISCORD_TOKEN="xyz" dotnet run --project DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj export --channel 869238366951079956 --output . --media --reuse-media --markdown false --format Json --after 1296272363444375632 --before 1312437546873131059

$ stat -c '%y' "Tyrrrz: Open Source - 📦 Projects - youtube-downloader [869238366951079956] (2024-10-17 to 2024-11-30).json_Files"/image*.png
2024-11-01 02:30:27.462000000 +0530
2024-11-17 15:37:14.379000000 +0530
2024-11-01 03:45:28.735000000 +0530
2024-11-01 03:31:24.518000000 +0530
2024-11-22 14:50:38.695000000 +0530
2024-10-29 15:21:46.986000000 +0530
2024-11-01 03:45:28.735000000 +0530
2024-11-03 20:56:30.421000000 +0530
2024-11-01 03:48:04.651000000 +0530
2024-11-01 03:37:37.762000000 +0530
2024-11-01 03:31:24.518000000 +0530
2024-11-01 03:37:37.762000000 +0530
2024-11-01 03:28:05.389000000 +0530
2024-11-01 03:45:28.735000000 +0530

Not sure if this is the best approach to implement this, but it seems to work well enough for my current use-case.

@Tyrrrz Tyrrrz added the bug label Dec 1, 2024
@Tyrrrz Tyrrrz requested a review from Copilot December 1, 2024 16:56

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (1)

DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs:54

  • The indentation of the 'if (timestamp is null)' block is incorrect. It should be aligned with the rest of the code.
{
@Tyrrrz Tyrrrz changed the title Prefer message timestamp over last-modified header for attachments Prefer message timestamp over the last-modified header for asset file dates Dec 12, 2024
@Tyrrrz Tyrrrz merged commit a9acf17 into Tyrrrz:master Dec 12, 2024
25 checks passed
@ritiek ritiek deleted the prefer-message-timestamp-for-attachments branch January 4, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using last-modified for populating attachment timestamps isn't reliable
2 participants