Added missing file attachment attributes in JsonAttachment output

Closes #1217
Fixes #1216
This commit is contained in:
signals-from-outer-space 2023-04-02 08:34:43 +02:00 committed by AsamK
parent 49591aedb4
commit db42f61cbb

View file

@ -2,12 +2,33 @@ package org.asamk.signal.json;
import org.asamk.signal.manager.api.MessageEnvelope; import org.asamk.signal.manager.api.MessageEnvelope;
record JsonAttachment(String contentType, String filename, String id, Long size) { record JsonAttachment(
String contentType,
String filename,
String id,
Long size,
Integer width,
Integer height,
String caption,
Long uploadTimestamp
) {
static JsonAttachment from(MessageEnvelope.Data.Attachment attachment) { static JsonAttachment from(MessageEnvelope.Data.Attachment attachment) {
final var id = attachment.id().orElse(null); final var id = attachment.id().orElse(null);
final var filename = attachment.fileName().orElse(null); final var filename = attachment.fileName().orElse(null);
final var size = attachment.size().orElse(null); final var size = attachment.size().orElse(null);
return new JsonAttachment(attachment.contentType(), filename, id, size); final var width = attachment.width().orElse(null);
final var height = attachment.height().orElse(null);
final var caption = attachment.caption().orElse(null);
final var uploadTimestamp = attachment.uploadTimestamp().orElse(null);
return new JsonAttachment(attachment.contentType(),
filename,
id,
size,
width,
height,
caption,
uploadTimestamp);
} }
} }