]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/json/JsonQuote.java
f0d1831c5b9a7e0a6a78573e39356f5fc2ed32c1
1 package org
.asamk
.signal
.json
;
3 import com
.fasterxml
.jackson
.annotation
.JsonInclude
;
5 import org
.asamk
.signal
.manager
.Manager
;
6 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceDataMessage
;
8 import java
.util
.ArrayList
;
10 import java
.util
.stream
.Collectors
;
12 import static org
.asamk
.signal
.util
.Util
.getLegacyIdentifier
;
14 public record JsonQuote(
16 @Deprecated String author
,
20 @JsonInclude(JsonInclude
.Include
.NON_NULL
) List
<JsonMention
> mentions
,
21 List
<JsonQuotedAttachment
> attachments
24 static JsonQuote
from(SignalServiceDataMessage
.Quote quote
, Manager m
) {
25 final var id
= quote
.getId();
26 final var address
= m
.resolveSignalServiceAddress(quote
.getAuthor());
27 final var author
= getLegacyIdentifier(address
);
28 final var authorNumber
= address
.getNumber().orNull();
29 final var authorUuid
= address
.getUuid().toString();
30 final var text
= quote
.getText();
32 final List
<JsonMention
> mentions
;
33 if (quote
.getMentions() != null && quote
.getMentions().size() > 0) {
34 mentions
= quote
.getMentions()
36 .map(quotedMention
-> JsonMention
.from(quotedMention
, m
))
37 .collect(Collectors
.toList());
42 final List
<JsonQuotedAttachment
> attachments
;
43 if (quote
.getAttachments().size() > 0) {
44 attachments
= quote
.getAttachments().stream().map(JsonQuotedAttachment
::from
).collect(Collectors
.toList());
46 attachments
= new ArrayList
<>();
49 return new JsonQuote(id
, author
, authorNumber
, authorUuid
, text
, mentions
, attachments
);