mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
Email clients tend to sort emails by the "Date" header, which is not when the email was received -- emails can be arbitrarily delayed during relaying. Messages without a Date header (as all Zulip messages previously) have one inserted by the first mailserver they encounter. As there are now multiple email-sending queues, we would like the view of the database, as presented by the emails that are sent out, to be consistent based on the Date header, which may not be the same as when the client gets the email in their inbox. Insert a Date header of when the Zulip system inserted the data into the local queue, as that encodes when the full information was pulled from the database. This also opens the door to multiple workers servicing the email_senders queue, to limit backlogging during large notifications, without having to worry about inconsistent delivery order between those two workers. Messages which are sent synchronously via `send_email()` get a Date header of when we attempt to send the message; this is, in practice, no different from Django's default behaviour of doing so, but makes the behaviour slightly more consistent.