mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-24 16:51:07 +01:00
Merge pull request #4269 from vector-im/feature/bma/required_signature
Make MegolmBackupAuthData.signatures optional for robustness
This commit is contained in:
commit
89e8e5ca31
1
changelog.d/4162.bugfix
Normal file
1
changelog.d/4162.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Make MegolmBackupAuthData.signatures optional for robustness
|
@ -410,7 +410,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||||||
val keysBackupVersionTrust = KeysBackupVersionTrust()
|
val keysBackupVersionTrust = KeysBackupVersionTrust()
|
||||||
val authData = keysBackupVersion.getAuthDataAsMegolmBackupAuthData()
|
val authData = keysBackupVersion.getAuthDataAsMegolmBackupAuthData()
|
||||||
|
|
||||||
if (authData == null || authData.publicKey.isEmpty() || authData.signatures.isEmpty()) {
|
if (authData == null || authData.publicKey.isEmpty() || authData.signatures.isNullOrEmpty()) {
|
||||||
Timber.v("getKeysBackupTrust: Key backup is absent or missing required data")
|
Timber.v("getKeysBackupTrust: Key backup is absent or missing required data")
|
||||||
return keysBackupVersionTrust
|
return keysBackupVersionTrust
|
||||||
}
|
}
|
||||||
@ -478,7 +478,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||||||
cryptoCoroutineScope.launch(coroutineDispatchers.main) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.main) {
|
||||||
val updateKeysBackupVersionBody = withContext(coroutineDispatchers.crypto) {
|
val updateKeysBackupVersionBody = withContext(coroutineDispatchers.crypto) {
|
||||||
// Get current signatures, or create an empty set
|
// Get current signatures, or create an empty set
|
||||||
val myUserSignatures = authData.signatures[userId].orEmpty().toMutableMap()
|
val myUserSignatures = authData.signatures?.get(userId).orEmpty().toMutableMap()
|
||||||
|
|
||||||
if (trust) {
|
if (trust) {
|
||||||
// Add current device signature
|
// Add current device signature
|
||||||
@ -497,7 +497,7 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||||||
// Create an updated version of KeysVersionResult
|
// Create an updated version of KeysVersionResult
|
||||||
val newMegolmBackupAuthData = authData.copy()
|
val newMegolmBackupAuthData = authData.copy()
|
||||||
|
|
||||||
val newSignatures = newMegolmBackupAuthData.signatures.toMutableMap()
|
val newSignatures = newMegolmBackupAuthData.signatures.orEmpty().toMutableMap()
|
||||||
newSignatures[userId] = myUserSignatures
|
newSignatures[userId] = myUserSignatures
|
||||||
|
|
||||||
val newMegolmBackupAuthDataWithNewSignature = newMegolmBackupAuthData.copy(
|
val newMegolmBackupAuthDataWithNewSignature = newMegolmBackupAuthData.copy(
|
||||||
|
@ -51,7 +51,7 @@ data class MegolmBackupAuthData(
|
|||||||
* userId -> (deviceSignKeyId -> signature)
|
* userId -> (deviceSignKeyId -> signature)
|
||||||
*/
|
*/
|
||||||
@Json(name = "signatures")
|
@Json(name = "signatures")
|
||||||
val signatures: Map<String, Map<String, String>>
|
val signatures: Map<String, Map<String, String>>? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun toJsonDict(): JsonDict {
|
fun toJsonDict(): JsonDict {
|
||||||
|
Loading…
Reference in New Issue
Block a user