Fixing issue described in ENG-10144#comment-16a38c06.
Tracked in ENG-10182.
Make sure all objects created in this function are freed. It is not as easy as in keyserver to create a generic function that handles it, as logic on the client is a lot more complicated and different between content and notif.
I tried to avoid returning olm.Account from this function, but it was not something we could easily do, I tried multiple solutions and all of them were a lot longer and less readable. Additionally, This really complex logic was stabilized for a long time and I don't want to tinker with this code.
Depends on D14349