When editing a draft created by Apple Mail on the web client and then
later sending the draft with Apple Mail, we need to delete the draft
ourselves, or it will remain in the Draft folder.
This patch makes sure that the deletion of said draft only occurs after
the message was successfully sent.
If a SMPT client keeps hammering bridge and triggers multiple successive
errors in quick succession, force that client to wait 20 seconds before
trying again.
If an IMAP client creates a new message as a reply/forward from an
existing draft, that draft will be deleted once the message has been
sent.
Other than not being the correct behavior, the original reason for which
this line of code was added (carried over from v2), seems to be no longer
necessary as in all tests, the message is correctly removed from the
drafts folder after sent.
If we update the address after determining the sender address is
different, we also need to refresh the identity state in order to use
the right encryption keys.
* Only call `RemoveOnFail` on error. It was also called on success.
* Add some logging to track send times.
* Fix non-deterministic hash from `rfc8222.GetMessageHash`.
https://github.com/ProtonMail/gluon/pull/395
Rather than having the services subscribe to each individual event type,
have only one subscriber for the whole event object. This spreads the
logic to the service through the `EventHandler` type.
This is important for the next stage where the IMAP service will be
required to apply events from the past.
Rather than accessing the Bridge user list, each user register their
individual SMTP service with the server manager.
Note that some dependencies on the user data are hidden behind the
`UserInterface`. These will be removed in a future patch.
Refactor code to isolate the SMTP functionality in a dedicated SMTP
service for each user as discussed in the Bridge Service Architecture
RFC.
Some shared types have been moved from `user` to `usertypes` so that
they can be shared with Service and User Code.
Finally due to lack of recursive imports, the user data SMTP needs
access to is hidden behind an interface until the User Identity service
is implemented.