Skip to content

Conversation

@ncjsvr
Copy link

@ncjsvr ncjsvr commented Feb 12, 2026

What this does

Discord CDN links expire after about 24 hours so any images/attachments in old logs just break. This adds an optional background archiver that downloads them before they expire and stores them in Mongodb GridFS so they always load.

Fixes #80 - #80

Changes

  • Added a new archiver module that runs in the background, scans logs for discord cdn urls, downloads them and stores in gridfs. Compresses images to jpeg to save space. Has configurable interval, retention, quality etc
  • Updated models so when viewing a log, it checks if attachments have been archived and swaps in the server url instead of the discord one
  • Added an /attachments/ route to serve the archived files
  • Updated env example, app config, and readme with the new config options
  • Updated dockerfile, pipfile, and requirements to add aiohttp and pillow
  • Added logging so you can see this process in console.

Config

Off by default, set SAVE_ATTACHMENTS=yes to enable. All the options are in the env example file.

Edit

Just wanted to say I have 72 archived attachments in my mongo database and it uses 3mb currently.

…URLs

Discord's signed CDN URLs expire after ~24h, breaking images in logs.
This adds an optional background archiver
downloads attachments and avatars before they expire, compresses images
to JPEG, and stores them in MongoDB GridFS. Archived files are served
via a new /attachments/ route. Configurable retention period, image
quality, max resolution, and scan interval.

To fix modmail-dev#80
Changed the mongo query from `$ne: []` as it was matching 0 logs, now checking messages.attachments.0 instead which picks up the attachments and loads them correctly in the log viewer.
Added more detailed logging so you can understand what's happening in the console.
@martinbndr
Copy link

In general I like the idea but in my opinion most of the users are relying on the free mongodb tier which has limited data storage. So many of them wouldn't really benefit from this feature as it gets limited quickly by the said storage limitation.

@ncjsvr
Copy link
Author

ncjsvr commented Feb 12, 2026

In general I like the idea but in my opinion most of the users are relying on the free mongodb tier which has limited data storage. So many of them wouldn't really benefit from this feature as it gets limited quickly by the said storage limitation.

Understand your point, right now I have 72 archived attachments in my mongo database and it uses 3mb currently. However I did add the compression settings and retention periods.

I think it probably depends how big your server is, this was tested in a 10k member server and we got those 72 images in 3 days. Any server that heavily relies on modmail more may have problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Images in messages affected by Discord's new Signed Attachment CDN URLs

2 participants