1 package org
.asamk
.signal
.json
;
3 import com
.fasterxml
.jackson
.annotation
.JsonProperty
;
5 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceAttachment
;
10 final String contentType
;
13 final String filename
;
21 JsonAttachment(SignalServiceAttachment attachment
) {
22 this.contentType
= attachment
.getContentType();
24 if (attachment
.isPointer()) {
25 final var pointer
= attachment
.asPointer();
26 this.id
= pointer
.getRemoteId().toString();
27 this.filename
= pointer
.getFileName().orNull();
28 this.size
= pointer
.getSize().transform(Integer
::longValue
).orNull();
30 final var stream
= attachment
.asStream();
32 this.filename
= stream
.getFileName().orNull();
33 this.size
= stream
.getLength();
37 JsonAttachment(String filename
) {
38 this.filename
= filename
;
39 this.contentType
= null;