sc: recover from ex-subscriber re-subscribing
context
- we want to be able to delete user data from the protocol store (identity/session) when they unsusbscribe to our channels
- to do this safely, we need to be able to recover a valid id and session if an unsubscribed user tries to subscribe again (but we deleted all their session data)
- a signalc accouht can reconstruct a valid session with a contact but ONLY if it initiates the session with an outgoing message. (incoming messages generate errors of the type below)
- SO! in this MR, we will handle the error generated by an incoming message from an unsubscribed user by responding with a message that will reconstruct a valid session and identity
behavior:
stub!
GIVEN i have unsubscrbied (and have no data in signalc store)
- WHEN i send a HELLO
- THEN i see a message that says (something like) "Sorry, we just had to do some crypto-crypto blah blah to talk to you again. Please resend!"
- WHEN i send HELLO again
- THEN i am resubscribed as normal
implementation notes:
- this is the error we have to handle
signalc_signalboost | {"type":"decryption_error","sender":{"number":"+16154804259","uuid":"362feb8e-17a0-402b-92d8-773df1b38a74"},"recipient":{"number":"+19096711587","uuid":"842cd970-9575-4a27-b10b-299c8f6ab551"},"error":{"cause":"java.lang.IllegalStateException","message":"invalid state for call to session_state to succeed: No session"}}----------------
signalc_signalboost |
signalc | 2021-06-02 16:39:39.611 [i.s.s.l.SignalReceiver] ERROR | Decryption Error:
signalc | java.lang.IllegalStateException: invalid state for call to session_state to succeed: No session
signalc | at org.signal.client.internal.Native.SessionCipher_DecryptSignalMessage(Native Method)
signalc | at org.whispersystems.libsignal.SessionCipher.decrypt(SessionCipher.java:126)
signalc | at org.whispersystems.signalservice.api.crypto.SignalServiceCipher.decrypt(SignalServiceCipher.java:185)
signalc | at org.whispersystems.signalservice.api.crypto.SignalServiceCipher.decrypt(SignalServiceCipher.java:138)
signalc | at info.signalboost.signalc.logic.SignalReceiver$relay$2.invokeSuspend(SignalReceiver.kt:188)
signalc | at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
signalc | at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
signalc | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
signalc | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
signalc | at java.base/java.lang.Thread.run(Thread.java:834)
Edited by aguestuser