discord-backup
discord-backup copied to clipboard
Store users separately from messages
Currently, the username and user avatar for the sender of a message are stored as part of the message. This takes up a lot of space in the serialized JSON (avatar URLs are longer than the average message), and precludes the ability to save avatars using Base64 (you'd save the entire image in Base64 once per message, resulting in infeasibly large backups).
Instead, during the backup, we can keep a map from user IDs to users, and store the poster's ID in the serialized message instead of the user data itself. When going over each message, we can simply check if we've encountered the poster before, and save their data if not.
Indeed it would be much more efficient. Feel free to submit a pull request if you know how to code this, otherwise I'll do it when I have time 👍