Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/harden-Client…
Browse files Browse the repository at this point in the history
…CapabilityDTO-for-api-v7

# Conflicts:
#	logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
  • Loading branch information
MohamadJaara committed Jan 7, 2025
2 parents f56f1ce + 361e87c commit a084dbb
Show file tree
Hide file tree
Showing 109 changed files with 3,229 additions and 377 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
name: Label PR based on title
runs-on: ubuntu-latest
steps:
- uses: srvaroa/labeler@v1.8.2
- uses: srvaroa/labeler@v1.13.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,55 @@

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.json.Json
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

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

@Serializable
data class CallClientList(
@SerialName("clients") val clients: List<CallClient>
) {
// TODO(optimization): Use a shared Json instance instead of creating one every time.
fun toJsonString(): String = Json { isLenient = true }.encodeToString(serializer(), this)
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
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.kalium.logic.data.call

import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.QualifiedID

data class InCallReactionMessage(
val conversationId: ConversationId,
val senderUserId: QualifiedID,
val emojis: Set<String>,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.kalium.logic.data.call

import com.wire.kalium.logic.data.conversation.Conversation

data class RecentlyEndedCallMetadata(
val callEndReason: Int,
val callDetails: CallDetails,
val conversationDetails: ConversationDetails,
val isTeamMember: Boolean
) {
data class CallDetails(
val isCallScreenShare: Boolean,
val screenShareDurationInSeconds: Long,
val callScreenShareUniques: Int,
val isOutgoingCall: Boolean,
val callDurationInSeconds: Long,
val callParticipantsCount: Int,
val conversationServices: Int,
val callAVSwitchToggle: Boolean,
val callVideoEnabled: Boolean
)

data class ConversationDetails(
val conversationType: Conversation.Type,
val conversationSize: Int,
val conversationGuests: Int,
val conversationGuestsPro: Int
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@
*/
package com.wire.kalium.logic.data.conversation

enum class ConversationFilter {
ALL,
FAVORITES,
GROUPS,
ONE_ON_ONE
import kotlinx.serialization.Serializable

@Serializable
sealed class ConversationFilter {
@Serializable
data object All : ConversationFilter()

@Serializable
data object Favorites : ConversationFilter()

@Serializable
data object Groups : ConversationFilter()

@Serializable
data object OneOnOne : ConversationFilter()

@Serializable
data class Folder(val folderName: String, val folderId: String) : ConversationFilter()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
package com.wire.kalium.logic.data.conversation

import com.wire.kalium.logic.data.id.QualifiedID
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ConversationFolder(
val id: String,
val name: String,
val type: FolderType
@SerialName("id") val id: String,
@SerialName("name") val name: String,
@SerialName("folder_type") val type: FolderType
)

data class FolderWithConversations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ sealed interface Message {
typeKey to "dataTransfer",
"content" to content.toLogMap(),
)

is MessageContent.InCallEmoji -> mutableMapOf(
typeKey to "inCallEmoji",
"content" to content.emojis
)
}

val standardProperties = mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ sealed interface MessageContent {

data class Cleared(
val conversationId: ConversationId,
val time: Instant
val time: Instant,
val needToRemoveLocally: Boolean
) : Signaling

// server message content types
Expand Down Expand Up @@ -394,6 +395,10 @@ sealed interface MessageContent {
data object Disabled : ForConversation()
}
}

data class InCallEmoji(
val emojis: Map<String, Int>
) : Signaling
}

/**
Expand Down Expand Up @@ -454,6 +459,7 @@ fun MessageContent?.getType() = when (this) {
is MessageContent.LegalHold.ForMembers.Disabled -> "LegalHold.ForMembers.Disabled"
is MessageContent.LegalHold.ForMembers.Enabled -> "LegalHold.ForMembers.Enabled"
is MessageContent.DataTransfer -> "DataTransfer"
is MessageContent.InCallEmoji -> "InCallEmoji"
null -> "null"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ inline fun MessageContent.FromProto.typeDescription(): String = when (this) {
is MessageContent.Receipt -> "Receipt"
is MessageContent.TextEdited -> "TextEdited"
is MessageContent.DataTransfer -> "DataTransfer"
is MessageContent.InCallEmoji -> "InCallEmoji"
}
26 changes: 13 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ activity-compose = "1.9.0"
app-compat = "1.6.1"
android-paging3 = "3.2.1"
cli-kt = "3.5.0"
coroutines = "1.8.0"
coroutines = "1.8.1"
compose-compiler = "1.5.13"
compose-ui = "1.6.6"
compose-ui = "1.7.6"
compose-material = "1.6.6"
cryptobox4j = "1.4.0"
cryptobox-android = "1.1.5"
Expand All @@ -17,14 +17,14 @@ okio = "3.9.0"
ok-http = "4.12.0"
mockative = "2.2.0"
android-work = "2.9.0"
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"
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"
androidx-arch = "2.2.0"
androidx-test-orchestrator = "1.4.2"
androidx-test-orchestrator = "1.5.1"
androidx-sqlite = "2.4.0"
benasher-uuid = "0.8.0"
benasher-uuid = "0.8.4"
ktx-datetime = { strictly = "0.5.0" }
ktx-serialization = "1.6.3"
ktx-atomicfu = "0.24.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 = "9.10.16"
avs = "10.0.1"
jna = "5.14.0"
core-crypto = "2.0.0"
core-crypto = "3.0.0"
core-crypto-multiplatform = "0.6.0-rc.3-multiplatform-pre1"
completeKotlin = "1.1.0"
desugar-jdk = "2.0.4"
desugar-jdk = "2.1.3"
kermit = "2.0.3"
detekt = "1.23.6"
detekt = "1.23.7"
agp = "8.5.2"
dokka = "1.8.20"
carthage = "0.0.1"
libsodiumBindings = "0.8.7"
protobufCodegen = "0.9.4"
annotation = "1.7.1"
annotation = "1.9.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 @@ -36,6 +36,7 @@ import com.wire.kalium.logic.data.message.MessageContent
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.data.user.UserRepository
import com.wire.kalium.logic.feature.call.usecase.ConversationClientsInCallUpdater
import com.wire.kalium.logic.feature.call.usecase.CreateAndPersistRecentlyEndedCallMetadataUseCase
import com.wire.kalium.logic.feature.call.usecase.GetCallConversationTypeProvider
import com.wire.kalium.logic.feature.message.MessageSender
import com.wire.kalium.logic.featureFlags.KaliumConfigs
Expand Down Expand Up @@ -103,6 +104,9 @@ class CallManagerTest {
@Mock
private val getCallConversationType = mock(GetCallConversationTypeProvider::class)

@Mock
private val createAndPersistRecentlyEndedCallMetadata = mock(CreateAndPersistRecentlyEndedCallMetadataUseCase::class)

private val dispatcher = TestKaliumDispatcher

private lateinit var callManagerImpl: CallManagerImpl
Expand Down Expand Up @@ -132,7 +136,8 @@ class CallManagerTest {
networkStateObserver = networkStateObserver,
kaliumConfigs = kaliumConfigs,
mediaManagerService = mediaManagerService,
flowManagerService = flowManagerService
flowManagerService = flowManagerService,
createAndPersistRecentlyEndedCallMetadata = createAndPersistRecentlyEndedCallMetadata
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.data.user.UserRepository
import com.wire.kalium.logic.feature.call.usecase.ConversationClientsInCallUpdater
import com.wire.kalium.logic.feature.call.usecase.GetCallConversationTypeProvider
import com.wire.kalium.logic.feature.call.usecase.CreateAndPersistRecentlyEndedCallMetadataUseCase
import com.wire.kalium.logic.feature.message.MessageSender
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import com.wire.kalium.network.NetworkStateObserver
Expand All @@ -56,7 +57,8 @@ actual class GlobalCallManager {
conversationClientsInCallUpdater: ConversationClientsInCallUpdater,
getCallConversationType: GetCallConversationTypeProvider,
networkStateObserver: NetworkStateObserver,
kaliumConfigs: KaliumConfigs
kaliumConfigs: KaliumConfigs,
createAndPersistRecentlyEndedCallMetadata: CreateAndPersistRecentlyEndedCallMetadataUseCase
): CallManager {
return CallManagerImpl()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import com.wire.kalium.logic.feature.call.scenario.OnSFTRequest
import com.wire.kalium.logic.feature.call.scenario.OnSendOTR
import com.wire.kalium.logic.feature.call.usecase.ConversationClientsInCallUpdater
import com.wire.kalium.logic.feature.call.usecase.GetCallConversationTypeProvider
import com.wire.kalium.logic.feature.call.usecase.CreateAndPersistRecentlyEndedCallMetadataUseCase
import com.wire.kalium.logic.feature.message.MessageSender
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import com.wire.kalium.logic.functional.fold
Expand Down Expand Up @@ -119,6 +120,7 @@ class CallManagerImpl internal constructor(
private val kaliumConfigs: KaliumConfigs,
private val mediaManagerService: MediaManagerService,
private val flowManagerService: FlowManagerService,
private val createAndPersistRecentlyEndedCallMetadata: CreateAndPersistRecentlyEndedCallMetadataUseCase,
private val json: Json = Json { ignoreUnknownKeys = true },
private val shouldRemoteMuteChecker: ShouldRemoteMuteChecker = ShouldRemoteMuteCheckerImpl(),
private val serverTimeHandler: ServerTimeHandler = ServerTimeHandlerImpl(),
Expand Down Expand Up @@ -219,7 +221,8 @@ class CallManagerImpl internal constructor(
callRepository = callRepository,
networkStateObserver = networkStateObserver,
scope = scope,
qualifiedIdMapper = qualifiedIdMapper
qualifiedIdMapper = qualifiedIdMapper,
createAndPersistRecentlyEndedCallMetadata = createAndPersistRecentlyEndedCallMetadata
).keepingStrongReference(),
metricsHandler = metricsHandler,
callConfigRequestHandler = OnConfigRequest(calling, callRepository, scope)
Expand Down Expand Up @@ -463,14 +466,19 @@ class CallManagerImpl internal constructor(
callClients: CallClientList
) {
withCalling {
// Needed to support calls between federated and non federated environments
// Mapping Needed to support calls between federated and non federated environments (domain separation)
val clients = callClients.clients.map { callClient ->
CallClient(
federatedIdMapper.parseToFederatedId(callClient.userId),
callClient.clientId
userId = federatedIdMapper.parseToFederatedId(callClient.userId),
clientId = callClient.clientId,
isMemberOfSubconversation = callClient.isMemberOfSubconversation,
quality = callClient.quality
)
}
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
Loading

0 comments on commit a084dbb

Please sign in to comment.