]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/api/MessageEnvelope.java
Update libsignal-service
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / api / MessageEnvelope.java
index 27c17650438b62f57a25319740a417d2d2376c04..d8438f5dce0ee0336dd50fe3171f1b64c9b85c75 100644 (file)
@@ -32,6 +32,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptM
 import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
 import org.whispersystems.signalservice.api.messages.multidevice.ViewOnceOpenMessage;
 import org.whispersystems.signalservice.api.messages.multidevice.ViewedMessage;
+import org.whispersystems.signalservice.api.push.ServiceId;
 
 import java.io.File;
 import java.io.IOException;
@@ -337,7 +338,8 @@ public record MessageEnvelope(
             }
 
             static Attachment from(
-                    SignalServiceDataMessage.Quote.QuotedAttachment a, final AttachmentFileProvider fileProvider
+                    SignalServiceDataMessage.Quote.QuotedAttachment a,
+                    final AttachmentFileProvider fileProvider
             ) {
                 return new Attachment(Optional.empty(),
                         Optional.empty(),
@@ -389,7 +391,7 @@ public record MessageEnvelope(
             }
 
             public record Name(
-                    Optional<String> display,
+                    Optional<String> nickname,
                     Optional<String> given,
                     Optional<String> family,
                     Optional<String> prefix,
@@ -398,7 +400,7 @@ public record MessageEnvelope(
             ) {
 
                 static Name from(org.whispersystems.signalservice.api.messages.shared.SharedContact.Name name) {
-                    return new Name(name.getDisplay(),
+                    return new Name(name.getNickname(),
                             name.getGiven(),
                             name.getFamily(),
                             name.getPrefix(),
@@ -480,15 +482,15 @@ public record MessageEnvelope(
             ) {
 
                 static Address from(org.whispersystems.signalservice.api.messages.shared.SharedContact.PostalAddress address) {
-                    return new Address(Address.Type.from(address.getType()),
-                            address.getLabel(),
-                            address.getLabel(),
-                            address.getLabel(),
-                            address.getLabel(),
+                    return new Address(Type.from(address.getType()),
                             address.getLabel(),
-                            address.getLabel(),
-                            address.getLabel(),
-                            address.getLabel());
+                            address.getStreet(),
+                            address.getPobox(),
+                            address.getNeighborhood(),
+                            address.getCity(),
+                            address.getRegion(),
+                            address.getPostcode(),
+                            address.getCountry());
                 }
 
                 public enum Type {
@@ -509,9 +511,7 @@ public record MessageEnvelope(
 
         public record Preview(String title, String description, long date, String url, Optional<Attachment> image) {
 
-            static Preview from(
-                    SignalServicePreview preview, final AttachmentFileProvider fileProvider
-            ) {
+            static Preview from(SignalServicePreview preview, final AttachmentFileProvider fileProvider) {
                 return new Preview(preview.getTitle(),
                         preview.getDescription(),
                         preview.getDate(),
@@ -611,11 +611,12 @@ public record MessageEnvelope(
                     RecipientResolver recipientResolver,
                     RecipientAddressResolver addressResolver
             ) {
-                return new Blocked(blockedListMessage.getAddresses()
-                        .stream()
-                        .map(d -> addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(d))
-                                .toApiRecipientAddress())
-                        .toList(), blockedListMessage.getGroupIds().stream().map(GroupId::unknownVersion).toList());
+                return new Blocked(blockedListMessage.individuals.stream()
+                        .map(d -> new RecipientAddress(d.getAci() == null ? null : d.getAci().toString(),
+                                null,
+                                d.getE164(),
+                                null))
+                        .toList(), blockedListMessage.groupIds.stream().map(GroupId::unknownVersion).toList());
             }
         }
 
@@ -689,7 +690,9 @@ public record MessageEnvelope(
                 DELETE,
                 BLOCK,
                 BLOCK_AND_DELETE,
-                UNBLOCK_AND_ACCEPT;
+                UNBLOCK_AND_ACCEPT,
+                SPAM,
+                BLOCK_AND_SPAM;
 
                 static Type from(MessageRequestResponseMessage.Type type) {
                     return switch (type) {
@@ -699,6 +702,8 @@ public record MessageEnvelope(
                         case BLOCK -> BLOCK;
                         case BLOCK_AND_DELETE -> BLOCK_AND_DELETE;
                         case UNBLOCK_AND_ACCEPT -> UNBLOCK_AND_ACCEPT;
+                        case SPAM -> SPAM;
+                        case BLOCK_AND_SPAM -> BLOCK_AND_SPAM;
                     };
                 }
             }
@@ -715,7 +720,6 @@ public record MessageEnvelope(
             Optional<Busy> busy,
             List<IceUpdate> iceUpdate,
             Optional<Opaque> opaque,
-            boolean isMultiRing,
             boolean isUrgent
     ) {
 
@@ -731,17 +735,13 @@ public record MessageEnvelope(
                             .map(m -> m.stream().map(IceUpdate::from).toList())
                             .orElse(List.of()),
                     callMessage.getOpaqueMessage().map(Opaque::from),
-                    callMessage.isMultiRing(),
                     callMessage.isUrgent());
         }
 
-        public record Offer(long id, String sdp, Type type, byte[] opaque) {
+        public record Offer(long id, Type type, byte[] opaque) {
 
             static Offer from(OfferMessage offerMessage) {
-                return new Offer(offerMessage.getId(),
-                        offerMessage.getSdp(),
-                        Type.from(offerMessage.getType()),
-                        offerMessage.getOpaque());
+                return new Offer(offerMessage.getId(), Type.from(offerMessage.getType()), offerMessage.getOpaque());
             }
 
             public enum Type {
@@ -757,10 +757,10 @@ public record MessageEnvelope(
             }
         }
 
-        public record Answer(long id, String sdp, byte[] opaque) {
+        public record Answer(long id, byte[] opaque) {
 
             static Answer from(AnswerMessage answerMessage) {
-                return new Answer(answerMessage.getId(), answerMessage.getSdp(), answerMessage.getOpaque());
+                return new Answer(answerMessage.getId(), answerMessage.getOpaque());
             }
         }
 
@@ -798,10 +798,10 @@ public record MessageEnvelope(
             }
         }
 
-        public record IceUpdate(long id, String sdp, byte[] opaque) {
+        public record IceUpdate(long id, byte[] opaque) {
 
             static IceUpdate from(IceUpdateMessage iceUpdateMessage) {
-                return new IceUpdate(iceUpdateMessage.getId(), iceUpdateMessage.getSdp(), iceUpdateMessage.getOpaque());
+                return new IceUpdate(iceUpdateMessage.getId(), iceUpdateMessage.getOpaque());
             }
         }
 
@@ -832,9 +832,7 @@ public record MessageEnvelope(
             Optional<TextAttachment> textAttachment
     ) {
 
-        public static Story from(
-                SignalServiceStoryMessage storyMessage, final AttachmentFileProvider fileProvider
-        ) {
+        public static Story from(SignalServiceStoryMessage storyMessage, final AttachmentFileProvider fileProvider) {
             return new Story(storyMessage.getAllowsReplies().orElse(false),
                     storyMessage.getGroupContext().map(c -> GroupUtils.getGroupIdV2(c.getMasterKey())),
                     storyMessage.getFileAttachment().map(f -> Data.Attachment.from(f, fileProvider)),
@@ -852,7 +850,8 @@ public record MessageEnvelope(
         ) {
 
             static TextAttachment from(
-                    SignalServiceTextAttachment textAttachment, final AttachmentFileProvider fileProvider
+                    SignalServiceTextAttachment textAttachment,
+                    final AttachmentFileProvider fileProvider
             ) {
                 return new TextAttachment(textAttachment.getText(),
                         textAttachment.getStyle().map(Style::from),
@@ -904,8 +903,9 @@ public record MessageEnvelope(
             final AttachmentFileProvider fileProvider,
             Exception exception
     ) {
-        final var source = !envelope.isUnidentifiedSender() && envelope.hasSourceServiceId()
-                ? recipientResolver.resolveRecipient(envelope.getSourceAddress())
+        final var serviceId = envelope.getSourceServiceId().map(ServiceId::parseOrNull).orElse(null);
+        final var source = !envelope.isUnidentifiedSender() && serviceId != null
+                ? recipientResolver.resolveRecipient(serviceId)
                 : envelope.isUnidentifiedSender() && content != null
                         ? recipientResolver.resolveRecipient(content.getSender())
                         : exception instanceof ProtocolException e