Skip to content

Commit

Permalink
refactor: replace custom impl with hexToLong from the stdlib in 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
typfel committed Jul 24, 2023
1 parent aaefb3a commit 94aa0bf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.wire.kalium.network.api.base.authenticated.message

import com.wire.kalium.protobuf.otr.ClientId
import com.wire.kalium.protobuf.otr.ClientMismatchStrategy
import com.wire.kalium.protobuf.otr.QualifiedNewOtrMessage
import com.wire.kalium.protobuf.otr.QualifiedUserEntry
Expand All @@ -35,8 +36,8 @@ internal class EnvelopeProtoMapperImpl : EnvelopeProtoMapper {

private val otrClientEntryMapper = OtrClientEntryMapper()
private val otrUserIdMapper = provideOtrUserIdMapper()
private val otrClientIdMapper = OtrClientIdMapper()

@OptIn(ExperimentalStdlibApi::class)
override fun encodeToProtobuf(envelopeParameters: MessageApi.Parameters.QualifiedDefaultParameters): ByteArray {
val qualifiedEntries = envelopeParameters.recipients.entries.groupBy({ it.key.domain }) { userEntry ->
val clientEntries = userEntry.value.entries.map(otrClientEntryMapper::toOtrClientEntry)
Expand Down Expand Up @@ -81,7 +82,7 @@ internal class EnvelopeProtoMapperImpl : EnvelopeProtoMapper {

return QualifiedNewOtrMessage(
recipients = qualifiedEntries,
sender = otrClientIdMapper.toOtrClientId(envelopeParameters.sender),
sender = ClientId(envelopeParameters.sender.hexToLong()),
blob = envelopeParameters.externalBlob?.let { ByteArr(it) },
clientMismatchStrategy = strategy,
nativePush = envelopeParameters.nativePush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
package com.wire.kalium.network.api.base.authenticated.message

import com.wire.kalium.protobuf.otr.ClientEntry
import com.wire.kalium.protobuf.otr.ClientId
import pbandk.ByteArr

internal class OtrClientEntryMapper {

private val clientIdMapper = OtrClientIdMapper()
@OptIn(ExperimentalStdlibApi::class)
fun toOtrClientEntry(clientPayload: Map.Entry<String, ByteArray>): ClientEntry = ClientEntry(
client = clientIdMapper.toOtrClientId(clientPayload.key),
client = ClientId(clientPayload.key.hexToLong()),
text = ByteArr(clientPayload.value),
)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object QualifiedSendMessageRequestJson {

val validDefaultParameters = ValidJsonProvider(
MessageApi.Parameters.QualifiedDefaultParameters(
sender = "sender-client-it",
sender = USER_1_CLIENT_1,
externalBlob = "blob-id".toByteArray(),
nativePush = true,
recipients = mapOf(),
Expand Down

0 comments on commit 94aa0bf

Please sign in to comment.