Merge pull request #83 from ouchadam/dependabot/gradle/org.jetbrains.kotlinx-kotlinx-serialization-json-1.4.0

Bump kotlinx-serialization-json from 1.3.3 to 1.4.0
This commit is contained in:
Adam Brown 2022-08-19 17:41:28 +01:00 committed by GitHub
commit 702ef5d5cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -119,7 +119,7 @@ ext.Dependencies.with {
mavenCentral.with { mavenCentral.with {
kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVer}" kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVer}"
kotlinSerializationGradlePlugin = "org.jetbrains.kotlin:kotlin-serialization:${kotlinVer}" kotlinSerializationGradlePlugin = "org.jetbrains.kotlin:kotlin-serialization:${kotlinVer}"
kotlinSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3" kotlinSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0"
kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
kotlinCoroutinesTest = 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' kotlinCoroutinesTest = 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVer}" kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVer}"

View File

@ -17,8 +17,8 @@ internal object ApiTimelineMessageContentDeserializer : KSerializer<ApiTimelineE
require(decoder is JsonDecoder) require(decoder is JsonDecoder)
val element = decoder.decodeJsonElement() val element = decoder.decodeJsonElement()
return when (element.jsonObject["msgtype"]?.jsonPrimitive?.content) { return when (element.jsonObject["msgtype"]?.jsonPrimitive?.content) {
"m.text" -> ApiTimelineEvent.TimelineMessage.Content.Text.serializer().deserialize(decoder) "m.text" -> decoder.json.decodeFromJsonElement(ApiTimelineEvent.TimelineMessage.Content.Text.serializer(), element)
"m.image" -> ApiTimelineEvent.TimelineMessage.Content.Image.serializer().deserialize(decoder) "m.image" -> decoder.json.decodeFromJsonElement(ApiTimelineEvent.TimelineMessage.Content.Image.serializer(), element)
else -> ApiTimelineEvent.TimelineMessage.Content.Ignored else -> ApiTimelineEvent.TimelineMessage.Content.Ignored
} }
} }

View File

@ -17,8 +17,8 @@ internal object EncryptedContentDeserializer : KSerializer<ApiEncryptedContent>
require(decoder is JsonDecoder) require(decoder is JsonDecoder)
val element = decoder.decodeJsonElement() val element = decoder.decodeJsonElement()
return when (val algorithm = element.jsonObject["algorithm"]?.jsonPrimitive?.content) { return when (val algorithm = element.jsonObject["algorithm"]?.jsonPrimitive?.content) {
"m.olm.v1.curve25519-aes-sha2" -> ApiEncryptedContent.OlmV1.serializer().deserialize(decoder) "m.olm.v1.curve25519-aes-sha2" -> decoder.json.decodeFromJsonElement(ApiEncryptedContent.OlmV1.serializer(), element)
"m.megolm.v1.aes-sha2" -> ApiEncryptedContent.MegOlmV1.serializer().deserialize(decoder) "m.megolm.v1.aes-sha2" -> decoder.json.decodeFromJsonElement(ApiEncryptedContent.MegOlmV1.serializer(), element)
null -> ApiEncryptedContent.Unknown null -> ApiEncryptedContent.Unknown
else -> throw IllegalArgumentException("Unknown algorithm : $algorithm") else -> throw IllegalArgumentException("Unknown algorithm : $algorithm")
} }

View File

@ -23,6 +23,8 @@ private val AN_ENCRYPTED_ROOM_REPLY = aRoomReplyMessageEvent(
private val A_DECRYPTED_CONTENT = DecryptedContent.TimelineText(aTimelineTextEventContent(body = A_DECRYPTED_MESSAGE_CONTENT)) private val A_DECRYPTED_CONTENT = DecryptedContent.TimelineText(aTimelineTextEventContent(body = A_DECRYPTED_MESSAGE_CONTENT))
private val A_USER_CREDENTIALS = aUserCredentials() private val A_USER_CREDENTIALS = aUserCredentials()
private val json = Json { encodeDefaults = true }
class RoomEventsDecrypterTest { class RoomEventsDecrypterTest {
private val fakeMessageDecrypter = FakeMessageDecrypter() private val fakeMessageDecrypter = FakeMessageDecrypter()
@ -67,7 +69,7 @@ class RoomEventsDecrypterTest {
private fun givenEncryptedMessage(roomMessage: RoomEvent.Message, decryptsTo: DecryptedContent) { private fun givenEncryptedMessage(roomMessage: RoomEvent.Message, decryptsTo: DecryptedContent) {
val model = roomMessage.encryptedContent!!.toModel() val model = roomMessage.encryptedContent!!.toModel()
fakeMessageDecrypter.givenDecrypt(model) fakeMessageDecrypter.givenDecrypt(model)
.returns(aDecryptionSuccessResult(payload = JsonString(Json { encodeDefaults = true }.encodeToString(DecryptedContent.serializer(), decryptsTo)))) .returns(aDecryptionSuccessResult(payload = JsonString(json.encodeToString(DecryptedContent.serializer(), decryptsTo))))
} }
private fun givenEncryptedReply(roomReply: RoomEvent.Reply, decryptsTo: DecryptedContent) { private fun givenEncryptedReply(roomReply: RoomEvent.Reply, decryptsTo: DecryptedContent) {