File tree Expand file tree Collapse file tree 4 files changed +16
-9
lines changed
main/java/org/matrix/android/sdk
test/java/org/matrix/android/sdk/internal/session/event Expand file tree Collapse file tree 4 files changed +16
-9
lines changed Original file line number Diff line number Diff line change
1
+ Improve `Event.getClearContent()` and fix assignment issue that may help to decrypt last Event in the room list.
Original file line number Diff line number Diff line change @@ -219,10 +219,16 @@ data class Event(
219
219
}
220
220
221
221
/* *
222
- * @return the event content
222
+ * @return the event content.
223
+ * If the content is encrypted, it will return the decrypted content, or null if the content is not
224
+ * decrypted.
223
225
*/
224
226
fun getClearContent (): Content ? {
225
- return getDecryptedContent() ? : content
227
+ return if (isEncrypted()) {
228
+ getDecryptedContent()
229
+ } else {
230
+ content
231
+ }
226
232
}
227
233
228
234
/* *
Original file line number Diff line number Diff line change @@ -627,7 +627,7 @@ internal class RustCryptoService @Inject constructor(
627
627
}
628
628
629
629
private fun notifyRoomKeyReceived (
630
- roomId : String ,
630
+ roomId : String? ,
631
631
sessionId : String ,
632
632
) {
633
633
megolmSessionImportManager.dispatchNewSession(roomId, sessionId)
@@ -664,18 +664,18 @@ internal class RustCryptoService @Inject constructor(
664
664
when (event.type) {
665
665
EventType .ROOM_KEY -> {
666
666
val content = event.getClearContent().toModel<RoomKeyContent >() ? : return @forEach
667
- content.sessionKey
668
- val roomId = content.sessionId ? : return @forEach
669
- val sessionId = content.sessionId
667
+
668
+ val roomId = content.roomId
669
+ val sessionId = content.sessionId ? : return @forEach
670
670
671
671
notifyRoomKeyReceived(roomId, sessionId)
672
672
matrixConfiguration.cryptoAnalyticsPlugin?.onRoomKeyImported(sessionId, EventType .ROOM_KEY )
673
673
}
674
674
EventType .FORWARDED_ROOM_KEY -> {
675
675
val content = event.getClearContent().toModel<ForwardedRoomKeyContent >() ? : return @forEach
676
676
677
- val roomId = content.sessionId ? : return @forEach
678
- val sessionId = content.sessionId
677
+ val roomId = content.roomId
678
+ val sessionId = content.sessionId ? : return @forEach
679
679
680
680
notifyRoomKeyReceived(roomId, sessionId)
681
681
matrixConfiguration.cryptoAnalyticsPlugin?.onRoomKeyImported(sessionId, EventType .FORWARDED_ROOM_KEY )
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ class ValidDecryptedEventTest {
89
89
).toContent()
90
90
)
91
91
92
- val unValidatedContent = mixedEvent.getClearContent() .toModel<MessageTextContent >()
92
+ val unValidatedContent = mixedEvent.content .toModel<MessageTextContent >()
93
93
unValidatedContent?.body shouldBe " some message"
94
94
95
95
mixedEvent.toValidDecryptedEvent()?.clearContent?.toModel<MessageTextContent >() shouldBe null
You can’t perform that action at this time.
0 commit comments