signal-cli/src/main/java/org/asamk/signal/json/JsonAttachment.java
2021-11-06 12:17:50 +01:00

17 lines
631 B
Java

package org.asamk.signal.json;
import org.asamk.signal.manager.api.MessageEnvelope;
record JsonAttachment(String contentType, String filename, String id, Long size) {
static JsonAttachment from(MessageEnvelope.Data.Attachment attachment) {
final var id = attachment.id().orElse(null);
final var filename = attachment.fileName().orElse(null);
final var size = attachment.size().orElse(null);
return new JsonAttachment(attachment.contentType(), filename, id, size);
}
static JsonAttachment from(String filename) {
return new JsonAttachment(filename, null, null, null);
}
}