Skip to content

Commit

Permalink
Merge branch 'release/candidate' into feat/harden-ClientCapabilityDTO…
Browse files Browse the repository at this point in the history
…-for-api-v7
  • Loading branch information
yamilmedina authored Dec 11, 2024
2 parents f1ca8e1 + 5b8fd62 commit 6a93e45
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,21 @@

package com.wire.kalium.logic.data.call

import com.wire.kalium.util.serialization.LenientJsonSerializer
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.nullable
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.Json

@Serializable
data class CallClient(
@SerialName("userid") val userId: String,
@SerialName("clientid") val clientId: String,
@SerialName("in_subconv") val isMemberOfSubconversation: Boolean = false,
@SerialName("quality")
@Serializable(with = CallQuality.CallQualityAsIntSerializer::class)
val quality: CallQuality = CallQuality.LOW
@SerialName("in_subconv") val isMemberOfSubconversation: Boolean = false
)

@Serializable
data class CallClientList(
@SerialName("clients") val clients: List<CallClient>
) {
fun toJsonString(): String = LenientJsonSerializer.json.encodeToString(serializer(), this)
}

enum class CallQuality {
ANY,
LOW,
HIGH;

data object CallQualityAsIntSerializer : KSerializer<CallQuality> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("quality", PrimitiveKind.INT).nullable

override fun serialize(encoder: Encoder, value: CallQuality) {
encoder.encodeInt(value.ordinal)
}

@OptIn(ExperimentalSerializationApi::class)
override fun deserialize(decoder: Decoder): CallQuality {
val value = if (decoder.decodeNotNullMark()) decoder.decodeInt() else 0
return when (value) {
1 -> LOW
2 -> HIGH
else -> ANY
}
}
}
// TODO(optimization): Use a shared Json instance instead of creating one every time.
fun toJsonString(): String = Json { isLenient = true }.encodeToString(serializer(), this)
}
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ activity-compose = "1.9.0"
app-compat = "1.6.1"
android-paging3 = "3.2.1"
cli-kt = "3.5.0"
coroutines = "1.8.1"
coroutines = "1.8.0"
compose-compiler = "1.5.13"
compose-ui = "1.6.6"
compose-material = "1.6.6"
Expand All @@ -17,12 +17,12 @@ okio = "3.9.0"
ok-http = "4.12.0"
mockative = "2.2.0"
android-work = "2.9.0"
android-test-runner = "1.6.2"
android-test-core-ktx = "1.6.1"
android-test-rules = "1.6.1"
android-test-core = "1.6.1"
android-test-runner = "1.5.2"
android-test-core-ktx = "1.5.0"
android-test-rules = "1.5.0"
android-test-core = "1.5.0"
androidx-arch = "2.2.0"
androidx-test-orchestrator = "1.5.1"
androidx-test-orchestrator = "1.4.2"
androidx-sqlite = "2.4.0"
benasher-uuid = "0.8.0"
ktx-datetime = { strictly = "0.5.0" }
Expand All @@ -37,20 +37,20 @@ sqldelight = "2.0.1"
sqlcipher-android = "4.5.6"
pbandk = "0.14.2"
turbine = "1.1.0"
avs = "10.0.1"
avs = "9.10.16"
jna = "5.14.0"
core-crypto = "2.0.0"
core-crypto-multiplatform = "0.6.0-rc.3-multiplatform-pre1"
completeKotlin = "1.1.0"
desugar-jdk = "2.1.3"
desugar-jdk = "2.0.4"
kermit = "2.0.3"
detekt = "1.23.6"
agp = "8.5.2"
dokka = "1.8.20"
carthage = "0.0.1"
libsodiumBindings = "0.8.7"
protobufCodegen = "0.9.4"
annotation = "1.9.1"
annotation = "1.7.1"
mordant = "2.0.0-beta13"
apache-tika = "2.9.2"
mockk = "1.13.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,19 +463,14 @@ class CallManagerImpl internal constructor(
callClients: CallClientList
) {
withCalling {
// Mapping Needed to support calls between federated and non federated environments (domain separation)
// Needed to support calls between federated and non federated environments
val clients = callClients.clients.map { callClient ->
CallClient(
userId = federatedIdMapper.parseToFederatedId(callClient.userId),
clientId = callClient.clientId,
isMemberOfSubconversation = callClient.isMemberOfSubconversation,
quality = callClient.quality
federatedIdMapper.parseToFederatedId(callClient.userId),
callClient.clientId
)
}
val clientsJson = CallClientList(clients).toJsonString()
callingLogger.d(
"$TAG - wcall_request_video_streams() called -> Requesting video streams for conversation = ${conversationId.toLogString()}"
)
val conversationIdString = federatedIdMapper.parseToFederatedId(conversationId)
calling.wcall_request_video_streams(
inst = it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ internal class UserPropertiesEventReceiverImpl internal constructor(
}

is Event.UserProperty.FoldersUpdate -> {
handleFoldersUpdate(event)
Either.Right(Unit)
// TODO will be handled in 4.11.0
// handleFoldersUpdate(event)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import com.wire.kalium.logic.framework.TestEvent
import com.wire.kalium.logic.functional.Either
import io.mockative.Mock
import io.mockative.any
import io.mockative.coEvery
import io.mockative.coVerify
import io.mockative.every
import io.mockative.mock
import io.mockative.once
Expand All @@ -49,19 +47,19 @@ class UserPropertiesEventReceiverTest {
}.wasInvoked(exactly = once)
}

@Test
fun givenFoldersUpdateEvent_repositoryIsInvoked() = runTest {
val event = TestEvent.foldersUpdate()
val (arrangement, eventReceiver) = Arrangement()
.withUpdateConversationFolders()
.arrange()

eventReceiver.onEvent(event, TestEvent.liveDeliveryInfo)

coVerify {
arrangement.conversationFolderRepository.updateConversationFolders(any())
}.wasInvoked(exactly = once)
}
// @Test
// fun givenFoldersUpdateEvent_repositoryIsInvoked() = runTest {
// val event = TestEvent.foldersUpdate()
// val (arrangement, eventReceiver) = Arrangement()
// .withUpdateConversationFolders()
// .arrange()
//
// eventReceiver.onEvent(event, TestEvent.liveDeliveryInfo)
//
// coVerify {
// arrangement.conversationFolderRepository.updateConversationFolders(any())
// }.wasInvoked(exactly = once)
// }

private class Arrangement {

Expand All @@ -82,11 +80,11 @@ class UserPropertiesEventReceiverTest {
}.returns(Either.Right(Unit))
}

suspend fun withUpdateConversationFolders() = apply {
coEvery {
conversationFolderRepository.updateConversationFolders(any())
}.returns(Either.Right(Unit))
}
// suspend fun withUpdateConversationFolders() = apply {
// coEvery {
// conversationFolderRepository.updateConversationFolders(any())
// }.returns(Either.Right(Unit))
// }

fun arrange() = this to userPropertiesEventReceiver
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import com.wire.kalium.network.api.unbound.versioning.VersionInfoDTO

// They are not truly constants as set is not a primitive type, yet are treated as one in this context
@Suppress("MagicNumber")
val SupportedApiVersions = setOf(0, 1, 2, 4, 5, 6)
val SupportedApiVersions: Set<Int> = setOf(0, 1, 2, 4, 5, 6, 7)

// They are not truly constants as set is not a primitive type, yet are treated as one in this context
@Suppress("MagicNumber")
val DevelopmentApiVersions = setOf(7)
val DevelopmentApiVersions: Set<Int> = emptySet()

// You can use scripts/generate_new_api_version.sh or gradle task network:generateNewApiVersion to
// bump API version and generate all needed classes
Expand Down

This file was deleted.

0 comments on commit 6a93e45

Please sign in to comment.