nodemailer / wildduck

Opinionated email server
https://wildduck.email/
European Union Public License 1.2
1.91k stars 268 forks source link

Attachment preview #424

Closed ramezrafla closed 9 months ago

ramezrafla commented 2 years ago

@andris9 This project is fantastic, and fills a badly-needed gap. The fact that you store attachments in MongoDB is a stroke of genius (from experience with MS365, it seems be the case for them too, likely GMail as well).

Right now, after a month of usage, the only real gap we see is attachment preview. Any thoughts on how to implement? Happy to assist and PR. We could use libreoffice for the conversion like Nextcloud (Collabora to be exact)

andris9 commented 2 years ago

Thank you for the kind words.

Regarding attachment previews. One of the design decisions has been that WildDuck does not have external dependencies (except for MX-related stuff like Rspamd/ClamAV), it does not spawn external shell commands, and it does not use compiled dependencies. This limitation allows running WildDuck on a variety of system architectures. Creating image previews would be possible, as there are JPEG/PNG etc. libraries for Node.js, but it gets more difficult for other file types.

For now, you can tail new attachments added to the storage and create previews of these attachments outside of WildDuck.

For example:

  1. set up a change stream listener for the attachments.files collection
  2. if a new entry is detected, then push this info to a processing queue
  3. your processing worker would then read the attachment file from GridFS
  4. your processing worker would create a preview and store it somewhere. Convert the _id binary of the gridstore attachment file to a hex string and store it with the preview file
  5. when fetching message info from WIldDuck API and you get an attachments array, then each attachment has a hash value that is a hex string. If you have stored a preview file with the same hex _id string, then this preview is for that attachment.
ramezrafla commented 2 years ago

Thanks so much @andris9 for your courteous reply!

One of the design decisions has been that WildDuck does not have external dependencies (except for MX-related stuff like Rspamd/ClamAV), it does not spawn external shell commands, and it does not use compiled dependencies

Agreed, and that's one of its beauties. Collabora can be used within a docker container as a full black box. It is indeed compiled but easily accessible for any platform.

I'll play with it a bit more (look at Mongo Schema etc.) and revert with ideas / questions. I have a feeling with the right design choices, it could be a simpler task.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 15 days.