mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 19:10:38 +00:00
Convert RecipientAddress to record
This commit is contained in:
parent
c3a9022bec
commit
8867a7b9ee
14 changed files with 59 additions and 91 deletions
|
@ -9,8 +9,8 @@ public record JsonMention(@Deprecated String name, String number, String uuid, i
|
|||
static JsonMention from(MessageEnvelope.Data.Mention mention) {
|
||||
final var address = mention.recipient();
|
||||
return new JsonMention(address.getLegacyIdentifier(),
|
||||
address.getNumber().orElse(null),
|
||||
address.getUuid().map(UUID::toString).orElse(null),
|
||||
address.number().orElse(null),
|
||||
address.uuid().map(UUID::toString).orElse(null),
|
||||
mention.start(),
|
||||
mention.length());
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ public record JsonMessageEnvelope(
|
|||
if (envelope.sourceAddress().isPresent()) {
|
||||
final var sourceAddress = envelope.sourceAddress().get();
|
||||
source = sourceAddress.getLegacyIdentifier();
|
||||
sourceNumber = sourceAddress.getNumber().orElse(null);
|
||||
sourceUuid = sourceAddress.getUuid().map(UUID::toString).orElse(null);
|
||||
sourceNumber = sourceAddress.number().orElse(null);
|
||||
sourceUuid = sourceAddress.uuid().map(UUID::toString).orElse(null);
|
||||
sourceDevice = envelope.sourceDevice();
|
||||
} else if (exception instanceof UntrustedIdentityException e) {
|
||||
final var sender = e.getSender();
|
||||
source = sender.getLegacyIdentifier();
|
||||
sourceNumber = sender.getNumber().orElse(null);
|
||||
sourceUuid = sender.getUuid().map(UUID::toString).orElse(null);
|
||||
sourceNumber = sender.number().orElse(null);
|
||||
sourceUuid = sender.uuid().map(UUID::toString).orElse(null);
|
||||
sourceDevice = e.getSenderDevice();
|
||||
} else {
|
||||
source = null;
|
||||
|
|
|
@ -23,8 +23,8 @@ public record JsonQuote(
|
|||
final var id = quote.id();
|
||||
final var address = quote.author();
|
||||
final var author = address.getLegacyIdentifier();
|
||||
final var authorNumber = address.getNumber().orElse(null);
|
||||
final var authorUuid = address.getUuid().map(UUID::toString).orElse(null);
|
||||
final var authorNumber = address.number().orElse(null);
|
||||
final var authorUuid = address.uuid().map(UUID::toString).orElse(null);
|
||||
final var text = quote.text().orElse(null);
|
||||
|
||||
final var mentions = quote.mentions().size() > 0 ? quote.mentions()
|
||||
|
|
|
@ -17,8 +17,8 @@ public record JsonReaction(
|
|||
final var emoji = reaction.emoji();
|
||||
final var address = reaction.targetAuthor();
|
||||
final var targetAuthor = address.getLegacyIdentifier();
|
||||
final var targetAuthorNumber = address.getNumber().orElse(null);
|
||||
final var targetAuthorUuid = address.getUuid().map(UUID::toString).orElse(null);
|
||||
final var targetAuthorNumber = address.number().orElse(null);
|
||||
final var targetAuthorUuid = address.uuid().map(UUID::toString).orElse(null);
|
||||
final var targetSentTimestamp = reaction.targetSentTimestamp();
|
||||
final var isRemove = reaction.isRemove();
|
||||
return new JsonReaction(emoji,
|
||||
|
|
|
@ -17,8 +17,8 @@ record JsonSyncDataMessage(
|
|||
if (transcriptMessage.destination().isPresent()) {
|
||||
final var address = transcriptMessage.destination().get();
|
||||
return new JsonSyncDataMessage(address.getLegacyIdentifier(),
|
||||
address.getNumber().orElse(null),
|
||||
address.getUuid().map(UUID::toString).orElse(null),
|
||||
address.number().orElse(null),
|
||||
address.uuid().map(UUID::toString).orElse(null),
|
||||
JsonDataMessage.from(transcriptMessage.message()));
|
||||
|
||||
} else {
|
||||
|
|
|
@ -11,8 +11,8 @@ record JsonSyncReadMessage(
|
|||
static JsonSyncReadMessage from(MessageEnvelope.Sync.Read readMessage) {
|
||||
final var senderAddress = readMessage.sender();
|
||||
final var sender = senderAddress.getLegacyIdentifier();
|
||||
final var senderNumber = senderAddress.getNumber().orElse(null);
|
||||
final var senderUuid = senderAddress.getUuid().map(UUID::toString).orElse(null);
|
||||
final var senderNumber = senderAddress.number().orElse(null);
|
||||
final var senderUuid = senderAddress.uuid().map(UUID::toString).orElse(null);
|
||||
final var timestamp = readMessage.timestamp();
|
||||
return new JsonSyncReadMessage(sender, senderNumber, senderUuid, timestamp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue