Defer marking messages as sent/acked until file is uploaded
When sending data via a mailbox, we should defer marking messages as sent/acked until the file containing the encrypted data has been successfully uploaded to the mailbox.
This complicates the sync layer a bit, but it means we don't have to keep persistent records of sent/acked messages in case of a crash (#2226 (closed)), or of files awaiting upload in case of a crash or a connectivity loss (#2230 (closed)), so the design is simpler overall.
When the sync layer is writing messages and acks for a mailbox session, instead of recording the sent/acked message IDs in the DB it should record them via a deferred send handler. This handler will be provided by the upload worker that will subsequently upload the file (#2291 (closed)). If the upload is successful, the worker will then use the IDs recorded by the handler to mark the messages as sent/acked in the DB.
This approach relies on the fact that there will be one upload worker per contact, and thus messages that have been sent/acked but not yet marked as such in the DB will not be sent/acked concurrently in another mailbox session. (They may be sent/acked concurrently in another session via a low-latency transport, but this is what we want to happen if a low-latency connection becomes available during a mailbox upload.)
This ticket replaces #2226 (closed) and #2230 (closed), which unfortunately have already been implemented.