Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,36 @@
package com.wire.integrations.jvm.model

import com.wire.crypto.MLSGroupId
import com.wire.integrations.jvm.model.http.conversation.ConversationResponse

@JvmRecord
data class ConversationData(
val id: QualifiedId,
val name: String?,
val teamId: TeamId?,
val mlsGroupId: MLSGroupId
)
val mlsGroupId: MLSGroupId,
val type: Type
) {
enum class Type {
GROUP,
SELF,
ONE_TO_ONE;

companion object {
fun fromString(value: String): Type =
when (value) {
SELF.name -> SELF
ONE_TO_ONE.name -> ONE_TO_ONE
GROUP.name -> GROUP
else -> GROUP
}

fun fromApi(value: ConversationResponse.Type): Type =
when (value) {
ConversationResponse.Type.GROUP -> GROUP
ConversationResponse.Type.SELF -> SELF
ConversationResponse.Type.ONE_TO_ONE -> ONE_TO_ONE
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ internal class ConversationSqlLiteStorage(db: AppsSdkDatabase) : ConversationSto
domain = conversation.id.domain,
name = conversation.name,
mls_group_id = Base64.getEncoder().encodeToString(conversation.mlsGroupId.value),
team_id = conversation.teamId?.value?.toString()
team_id = conversation.teamId?.value?.toString(),
type = conversation.type.name
)
}

Expand Down Expand Up @@ -113,7 +114,8 @@ internal class ConversationSqlLiteStorage(db: AppsSdkDatabase) : ConversationSto
id = QualifiedId(UUID.fromString(conv.id), conv.domain),
name = conv.name,
teamId = conv.team_id?.let { TeamId(UUID.fromString(it)) },
mlsGroupId = MLSGroupId(Base64.getDecoder().decode(conv.mls_group_id))
mlsGroupId = MLSGroupId(Base64.getDecoder().decode(conv.mls_group_id)),
type = ConversationData.Type.fromString(value = conv.type)
)

private fun conversationMemberMapper(member: Conversation_member) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ internal class EventsRouter internal constructor(
id = qualifiedConversation,
name = conversationName,
mlsGroupId = mlsGroupId,
teamId = conversation.teamId?.let { TeamId(it) }
teamId = conversation.teamId?.let { TeamId(it) },
type = ConversationData.Type.fromApi(value = conversation.type)
)
val members = conversation.members.others.map {
ConversationMember(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS conversation (
team_id TEXT,
mls_group_id TEXT NOT NULL,
creation_date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
type TEXT NOT NULL,
PRIMARY KEY (id, domain)
);

Expand All @@ -18,9 +19,9 @@ FROM conversation
WHERE id = ? AND domain = ?;

insert:
INSERT INTO conversation(id, domain, name, team_id, mls_group_id)
VALUES (?, ?, ?, ?, ?)
ON CONFLICT(id, domain) DO UPDATE SET name=excluded.name, team_id=excluded.team_id, mls_group_id=excluded.mls_group_id;
INSERT INTO conversation(id, domain, name, team_id, mls_group_id, type)
VALUES (?, ?, ?, ?, ?, ?)
ON CONFLICT(id, domain) DO UPDATE SET name=excluded.name, team_id=excluded.team_id, mls_group_id=excluded.mls_group_id, type=excluded.type;

delete:
DELETE FROM conversation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class WireEventsTest {
id = CONVERSATION_ID,
name = "Test conversation",
teamId = null,
mlsGroupId = MLSGroupId(ByteArray(32) { 1 })
mlsGroupId = MLSGroupId(ByteArray(32) { 1 }),
type = ConversationData.Type.GROUP
),
members = emptyList()
)
Expand Down