mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
This return value was very complicated to understand. Some failure returns were returned as Err and some as Ok with no consistency, but resulting in the same behaviour. This refactor makes the handle_securejoin_handshake the sole place responsible for maintaining the state of the secure join process (context.bob) and also in charge of terminating the ongoing process. This is none of receive_imf's business. The remaining returns are now cleanly classified in application-errors and protocol errors: Applications errors result in an Err and mean there is a bug or something else serious went wrong, like database access suddenly failed or so. In this case receive_imf is still responsible for clearing the state and resetting ongoing-process. It may be possible this should still be moved back to securejoin.rs so that recieve_imf doesn't need to know anything about this either. Protocol errors are not failures for receive_imf, it just means the received message didn't follow the protocol. Receive_imf in this case is told to ignore the message: that is hide it but not delete it. Other Ok returns also only say what needs to happen to the message: - It's fully processed and needs no further processing, instead should be removed - It should still be processed as a normal received message. This changes some behaviour: if the chat creation/lookup for the contact fails this is treated as an application error. Previously this was silently ignored and send_msg() would be called with a 0 chat_id without checking the response. This resulted in the protocol quitely being blocked. This all shhould now make it easier to resultify more of the functions called by this function, instead of having to deal with very complicated application logic hidden in the return code.