Skip to content

Commit

Permalink
Merge branch 'release/tchap_v2.9.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Oct 6, 2023
2 parents 841f86c + fb63f24 commit d62b3b9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
8 changes: 8 additions & 0 deletions TCHAP_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Changes in Tchap 2.9.5 (2023-10-06)
===================================

Bugfixes 🐛
----------
- Correction des messages chiffrés quand il existe qu'une seule session ([#979](https://github.com/tchapgouv/tchap-android/issues/979))


Changes in Tchap 2.9.4 (2023-10-06)
===================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
import org.matrix.android.sdk.api.session.events.model.content.RoomKeyContent
import org.matrix.android.sdk.api.session.events.model.content.RoomKeyWithHeldContent
Expand Down Expand Up @@ -133,6 +134,7 @@ internal class RustCryptoService @Inject constructor(
private val getRoomUserIds: GetRoomUserIdsUseCase,
private val outgoingRequestsProcessor: OutgoingRequestsProcessor,
private val matrixConfiguration: MatrixConfiguration,
private val rateLimiter: PerSessionBackupQueryRateLimiter,
) : CryptoService {

private val isStarting = AtomicBoolean(false)
Expand Down Expand Up @@ -493,7 +495,30 @@ internal class RustCryptoService @Inject constructor(
*/
@Throws(MXCryptoError::class)
override suspend fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult {
return olmMachine.decryptRoomEvent(event)
return try {
olmMachine.decryptRoomEvent(event)
} catch (mxCryptoError: MXCryptoError) {
// Tchap: try to perform a lazy migration from legacy store if there is no other session.
if (mxCryptoError is MXCryptoError.Base && mxCryptoError.errorType == MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID) {
Timber.v("Try to perform a lazy migration from legacy store")
/**
* It's a bit hacky, check how this can be better integrated with rust?
*/
val content = event.content?.toModel<EncryptedEventContent>() ?: throw mxCryptoError
val roomId = event.roomId
val sessionId = content.sessionId
val senderKey = content.senderKey
if (roomId != null && sessionId != null) {
val legacy = tryOrNull("Failed to access legacy crypto store") {
cryptoStore.getInboundGroupSession(sessionId, senderKey.orEmpty())
}
if (legacy == null || olmMachine.importRoomKey(legacy).isFailure) {
rateLimiter.tryFromBackupIfPossible(sessionId, roomId)
}
}
}
throw mxCryptoError
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion towncrier.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.towncrier]
version = "2.9.4"
version = "2.9.5"
directory = "changelog.d"
filename = "TCHAP_CHANGES.md"
name = "Changes in Tchap"
Expand Down
2 changes: 1 addition & 1 deletion vector-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ext.versionMinor = 9
// Note: even values are reserved for regular release, odd values for hotfix release.
// When creating a hotfix, you should decrease the value, since the current value
// is the value for the next regular release.
ext.versionPatch = 4
ext.versionPatch = 5

static def getGitTimestamp() {
def cmd = 'git show -s --format=%ct'
Expand Down

0 comments on commit d62b3b9

Please sign in to comment.