Skip to content
Open
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 @@ -17,18 +17,11 @@
*/
package com.wire.kalium.network.api.authenticated.remoteBackup

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Response payload for fetching messages from the backup service
* Response payload for fetching events from the backup service.
*/
@Serializable
data class MessageSyncFetchResponseDTO(
@SerialName("has_more")
val hasMore: Boolean,
@SerialName("conversations")
val conversations: Map<String, ConversationMessagesDTO>,
@SerialName("pagination_token")
val events: List<RemoteBackupEventDTO>,
val paginationToken: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@
*/
package com.wire.kalium.network.api.authenticated.remoteBackup

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Request payload for synchronizing messages to the backup service
* Request payload for synchronizing messages to the backup service.
* Events can be upserts, deletes, or last-read updates.
*/
@Serializable
data class MessageSyncRequestDTO(
@SerialName("user_id")
val userId: String,
@SerialName("upserts")
val upserts: Map<String, List<MessageSyncUpsertDTO>>, // Map from conversation ID to list of upserts
@SerialName("deletions")
val deletions: Map<String, List<String>>, // Map from conversation ID to list of message IDs to delete
@SerialName("conversations_last_read")
val conversationsLastRead: Map<String, Long> = emptyMap() // Map from conversation ID to last read timestamp (epoch millis)
val events: List<RemoteBackupEventDTO>
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Wire
* Copyright (C) 2026 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.network.api.authenticated.remoteBackup

import com.wire.kalium.network.api.model.QualifiedID
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Sealed class representing different types of message content for sync.
* This mirrors the structure of BackupMessageContent.
*/
@Serializable
sealed class RemoteBAckupMessageContentDTO {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a typo in class name (uppercase A)


@Serializable
@SerialName("text")
data class Text(
@SerialName("text")
val text: String,
@SerialName("mentions")
val mentions: List<MessageSyncMentionDTO> = emptyList(),
@SerialName("quotedMessageId")
val quotedMessageId: String? = null
) : RemoteBAckupMessageContentDTO()

@Serializable
@SerialName("asset")
data class Asset(
@SerialName("mimeType")
val mimeType: String,
@SerialName("size")
val size: Int,
@SerialName("name")
val name: String?,
@SerialName("otrKey")
val otrKey: String,
@SerialName("sha256")
val sha256: String,
@SerialName("assetId")
val assetId: String,
@SerialName("assetToken")
val assetToken: String?,
@SerialName("assetDomain")
val assetDomain: String?,
@SerialName("encryption")
val encryption: String?,
@SerialName("metaData")
val metaData: MessageSyncAssetMetadataDTO?
) : RemoteBAckupMessageContentDTO()

@Serializable
@SerialName("location")
data class Location(
@SerialName("longitude")
val longitude: Float,
@SerialName("latitude")
val latitude: Float,
@SerialName("name")
val name: String?,
@SerialName("zoom")
val zoom: Int?
) : RemoteBAckupMessageContentDTO()
}

/**
* DTO for user mentions in text messages.
*/
@Serializable
data class MessageSyncMentionDTO(
@SerialName("userId")
val userId: QualifiedID,
@SerialName("start")
val start: Int,
@SerialName("length")
val length: Int
)

/**
* Sealed class representing different types of asset metadata.
*/
@Serializable
sealed class MessageSyncAssetMetadataDTO {

@Serializable
@SerialName("image")
data class Image(
@SerialName("width")
val width: Int,
@SerialName("height")
val height: Int,
@SerialName("tag")
val tag: String?
) : MessageSyncAssetMetadataDTO()

@Serializable
@SerialName("video")
data class Video(
@SerialName("width")
val width: Int?,
@SerialName("height")
val height: Int?,
@SerialName("duration")
val duration: Long?
) : MessageSyncAssetMetadataDTO()

@Serializable
@SerialName("audio")
data class Audio(
@SerialName("normalization")
val normalization: String?,
@SerialName("duration")
val duration: Long?
) : MessageSyncAssetMetadataDTO()

@Serializable
@SerialName("generic")
data class Generic(
@SerialName("name")
val name: String?
) : MessageSyncAssetMetadataDTO()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@
*/
package com.wire.kalium.network.api.authenticated.remoteBackup

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Messages and metadata for a single conversation
* Events exchanged with the remote backup service.
*/
@Serializable
data class ConversationMessagesDTO(
@SerialName("last_read")
val lastRead: Long? = null, // Last read timestamp (epoch millis)
@SerialName("messages")
val messages: List<MessageSyncResultDTO>
)
sealed class RemoteBackupEventDTO {

data class Upsert(
val messageId: String,
val timestamp: Long,
val payload: RemoteBackupPayloadDTO
) : RemoteBackupEventDTO()

data class Delete(
val conversationId: String,
val messageId: String
) : RemoteBackupEventDTO()

data class LastRead(
val conversationId: String,
val lastRead: Long
) : RemoteBackupEventDTO()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,28 @@
*/
package com.wire.kalium.network.api.authenticated.remoteBackup

import com.wire.kalium.network.api.model.QualifiedID
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Individual message result from fetch operation
* DTO representing the payload of a message sync operation.
* This mirrors the structure of BackupMessage for type-safe serialization.
*/
@Serializable
data class MessageSyncResultDTO(
@SerialName("timestamp")
val timestamp: Long,
@SerialName("message_id")
val messageId: String,
@SerialName("payload")
val payload: String // JSON-encoded string of BackupMessage
data class RemoteBackupPayloadDTO(
@SerialName("id")
val id: String,
@SerialName("conversationId")
val conversationId: QualifiedID,
@SerialName("senderUserId")
val senderUserId: QualifiedID,
@SerialName("senderClientId")
val senderClientId: String,
@SerialName("creationDate")
val creationDate: Long,
@SerialName("content")
val content: RemoteBAckupMessageContentDTO,
@SerialName("lastEditTime")
val lastEditTime: Long? = null
)
Loading
Loading