improvement: Include attachments metadata in the export

This commit is contained in:
Artem Chepurnoy 2024-07-19 10:37:22 +03:00
parent f80cc7f397
commit 4bd16a82a8
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
1 changed files with 20 additions and 0 deletions

View File

@ -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
//