File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
matrix-sdk-android/src/main/java/org/matrix/android/sdk Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -162,4 +162,9 @@ interface CryptoService {
162162 * send, in order to speed up sending of the message.
163163 */
164164 fun prepareToEncrypt (roomId : String , callback : MatrixCallback <Unit >)
165+
166+ /* *
167+ * Share existing inbound sessions with the provided userId devices
168+ */
169+ fun sendSharedHistoryKeys (roomId : String , userId : String )
165170}
Original file line number Diff line number Diff line change @@ -1370,7 +1370,23 @@ internal class DefaultCryptoService @Inject constructor(
13701370 )
13711371 }
13721372 }
1373-
1373+ override fun sendSharedHistoryKeys (roomId : String , userId : String ) {
1374+ cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
1375+ val userDevices = cryptoStore.getUserDevices(userId)
1376+ userDevices?.forEach {
1377+ // Lets share our existing inbound sessions for every user device
1378+ val deviceId = it.key
1379+ val inboundSessions = cryptoStore.getInboundGroupSessions(roomId)
1380+ inboundSessions.forEach { inboundGroupSession ->
1381+ // Share the session with the to userId with deviceId
1382+ val exportedKeys = inboundGroupSession.exportKeys()
1383+ val algorithm = exportedKeys?.algorithm
1384+ val decryptor = roomDecryptorProvider.getRoomDecryptor(roomId, algorithm)
1385+ decryptor?.shareKeysWithDevice(exportedKeys, deviceId, userId)
1386+ }
1387+ }
1388+ }
1389+ }
13741390 /* ==========================================================================================
13751391 * For test only
13761392 * ========================================================================================== */
You can’t perform that action at this time.
0 commit comments