From 4bd16a82a8cf396b5e3a9ef558a531cbe4f58493 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Fri, 19 Jul 2024 10:37:22 +0300 Subject: [PATCH] improvement: Include attachments metadata in the export --- .../service/export/impl/ExportServiceImpl.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/export/impl/ExportServiceImpl.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/export/impl/ExportServiceImpl.kt index 9e4f93a..8d820e3 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/export/impl/ExportServiceImpl.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/export/impl/ExportServiceImpl.kt @@ -146,6 +146,26 @@ class ExportServiceImpl( put("creationDate", instant = createdDate ?: revisionDate) put("deletedDate", deletedDate) + run { + val key = "attachments" + // TODO: Export local attachments with their + // local identifier. + val remoteAttachments = attachments + .mapNotNull { it as? DSecret.Attachment.Remote } + if (remoteAttachments.isNotEmpty()) { + putJsonArray(key) { + remoteAttachments.forEach { attachment -> + val obj = buildJsonObject { + put("id", attachment.remoteCipherId) + put("size", attachment.size) + put("fileName", attachment.fileName) + } + add(obj) + } + } + } + } + // // Type //