1 package org
.asamk
.signal
.json
;
3 import com
.fasterxml
.jackson
.annotation
.JsonProperty
;
5 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceAttachment
;
6 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceAttachmentPointer
;
7 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceAttachmentStream
;
12 final String contentType
;
15 final String filename
;
23 JsonAttachment(SignalServiceAttachment attachment
) {
24 this.contentType
= attachment
.getContentType();
26 if (attachment
.isPointer()) {
27 final SignalServiceAttachmentPointer pointer
= attachment
.asPointer();
28 this.id
= pointer
.getRemoteId().toString();
29 this.filename
= pointer
.getFileName().orNull();
30 this.size
= pointer
.getSize().transform(Integer
::longValue
).orNull();
32 final SignalServiceAttachmentStream stream
= attachment
.asStream();
34 this.filename
= stream
.getFileName().orNull();
35 this.size
= stream
.getLength();
39 JsonAttachment(String filename
) {
40 this.filename
= filename
;
41 this.contentType
= null;