https://github.com/signalapp/Signal-Android/commit/8bc7d1b7f52b41cafb2a58197fb413aeb5271626 Skip to content Sign up * Why GitHub? + Features + Mobile + Actions + Codespaces + Packages + Security + Code review + Issues + Integrations + GitHub Sponsors + Customer stories * Team * Enterprise * Explore + Explore GitHub + Learn and contribute + Topics + Collections + Trending + Learning Lab + Open source guides + Connect with others + The ReadME Project + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing + Plans + Compare plans + Contact Sales + Education [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} signalapp / Signal-Android Public * * Notifications * Fork 5.3k * Star 21.8k * * Code * Issues 1.4k * Pull requests 232 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights Permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files Drop messages that have a story context. * Loading branch information @greyson-signal @alex-signal greyson-signal authored and alex-signal committed Jan 7, 2022 1 parent 4dae424 commit 8bc7d1b7f52b41cafb2a58197fb413aeb5271626 Split Unified Showing 5 changed files with 86 additions and 9 deletions. 1. +5 -0 app/src/main/java/org/thoughtcrime/securesms/messages/ MessageContentProcessor.java 2. +8 -0 libsignal/service/src/main/java/org/whispersystems/ signalservice/api/SignalServiceMessageSender.java 3. +17 -1 ...nal/service/src/main/java/org/whispersystems/ signalservice/api/messages/SignalServiceContent.java 4. +50 -8 ...service/src/main/java/org/whispersystems/signalservice /api/messages/SignalServiceDataMessage.java 5. +6 -0 libsignal/service/src/main/proto/SignalService.proto There are no files selected for viewing 5 app/src/main/java/org/thoughtcrime/securesms/messages/ MessageContentProcessor.java [*] Show comments View file Edit file Delete file This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters @@ -259,6 +259,7 @@ private void handleMessage(@NonNull SignalServiceContent content, long timestamp else if (message.getReaction().isPresent()) messageId = handleReaction(content, message, senderRecipient); else if (message.getRemoteDelete().isPresent()) messageId = handleRemoteDelete(content, message, senderRecipient); else if (message.getPayment().isPresent()) handlePayment(content, message, senderRecipient); else if (message.getStoryContext().isPresent()) handleStoryMessage (content); else if (isMediaMessage) messageId = handleMediaMessage(content, message, smsMessageId, senderRecipient, threadRecipient, receivedTime); else if (message.getBody().isPresent()) messageId = handleTextMessage(content, message, smsMessageId, groupId, senderRecipient, threadRecipient, receivedTime); else if (Build.VERSION.SDK_INT > 19 && message.getGroupCallUpdate() .isPresent()) handleGroupCallUpdateMessage(content, message, groupId, senderRecipient); @@ -1256,6 +1257,10 @@ private void handleSynchronizeViewOnceOpenMessage(@NonNull ViewOnceOpenMessage o messageNotifier.updateNotification(context); } private void handleStoryMessage(SignalServiceContent content) { warn(content.getTimestamp(), "Detected a story reply. We do not support this yet. Dropping."); } private @Nullable MessageId handleMediaMessage(@NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message, @NonNull Optional smsMessageId, 8 ...ervice/src/main/java/org/whispersystems/signalservice/api/ SignalServiceMessageSender.java [*] Show comments View file Edit file Delete file This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters @@ -901,6 +901,14 @@ private Content createMessageContent (SignalServiceDataMessage message) throws IO } } if (message.getStoryContext().isPresent()) { SignalServiceDataMessage.StoryContext storyContext = message. getStoryContext().get(); builder.setStoryContext(DataMessage.StoryContext.newBuilder() .setAuthorUuid(storyContext.getAuthorAci().toString()) .setSentTimestamp(storyContext.getSentTimestamp())); } builder.setTimestamp(message.getTimestamp()); return enforceMaxContentSize(container.setDataMessage(builder). build()); 18 ...ice/src/main/java/org/whispersystems/signalservice/api/messages /SignalServiceContent.java [*] Show comments View file Edit file Delete file This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters @@ -529,6 +529,7 @@ private static SignalServiceDataMessage createSignalServiceMessage(SignalService SignalServiceDataMessage.Reaction reaction = createReaction (content); SignalServiceDataMessage.RemoteDelete remoteDelete = createRemoteDelete(content); SignalServiceDataMessage.GroupCallUpdate groupCallUpdate = createGroupCallUpdate(content); SignalServiceDataMessage.StoryContext storyContext = createStoryContext(content); if (content.getRequiredProtocolVersion() > SignalServiceProtos. DataMessage.ProtocolVersion.CURRENT_VALUE) { throw new UnsupportedDataMessageProtocolVersionException( SignalServiceProtos.DataMessage.ProtocolVersion.CURRENT_VALUE, @@ -577,7 +578,8 @@ private static SignalServiceDataMessage createSignalServiceMessage(SignalService reaction, remoteDelete, groupCallUpdate, payment); payment, storyContext); } private static SignalServiceSyncMessage createSynchronizeMessage( SignalServiceMetadata metadata, @@ -1036,6 +1038,20 @@ private static SignalServiceTypingMessage createTypingMessage(SignalServiceMetad } } private static SignalServiceDataMessage.StoryContext createStoryContext(SignalServiceProtos.DataMessage content) throws InvalidMessageStructureException { if (!content.hasStoryContext()) { return null; } ACI aci = ACI.parseOrNull(content.getStoryContext().getAuthorUuid ()); if (aci == null) { throw new InvalidMessageStructureException("Invalid author ACI!"); } return new SignalServiceDataMessage.StoryContext(aci, content. getStoryContext().getSentTimestamp()); } private static SignalServiceDataMessage.PaymentNotification createPaymentNotification(SignalServiceProtos.DataMessage.Payment content) throws InvalidMessageStructureException { 58 ...src/main/java/org/whispersystems/signalservice/api/messages/ SignalServiceDataMessage.java [*] Show comments View file Edit file Delete file This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters @@ -16,7 +16,6 @@ import java.util.LinkedList; import java.util.List; import java.util.UUID; /** * Represents a decrypted Signal Service data message. @@ -42,6 +41,7 @@ private final Optional remoteDelete; private final Optional groupCallUpdate; private final Optional payment; private final Optional storyContext; /** * Construct a SignalServiceDataMessage. @@ -55,14 +55,26 @@ * @param expiresInSeconds Number of seconds in which the message should disappear after being seen. */ SignalServiceDataMessage(long timestamp, SignalServiceGroup group, SignalServiceGroupV2 groupV2, SignalServiceGroup group, SignalServiceGroupV2 groupV2, List attachments, String body, boolean endSession, int expiresInSeconds, boolean expirationUpdate, byte[] profileKey, boolean profileKeyUpdate, Quote quote, List sharedContacts, List previews, List mentions, Sticker sticker, boolean viewOnce, Reaction reaction, RemoteDelete remoteDelete, String body, boolean endSession, int expiresInSeconds, boolean expirationUpdate, byte[] profileKey, boolean profileKeyUpdate, Quote quote, List sharedContacts, List previews, List mentions, Sticker sticker, boolean viewOnce, Reaction reaction, RemoteDelete remoteDelete, GroupCallUpdate groupCallUpdate, Payment payment) Payment payment, StoryContext storyContext) { try { this.group = SignalServiceGroupContext.createOptional(group, groupV2); @@ -84,6 +96,7 @@ this.remoteDelete = Optional.fromNullable(remoteDelete); this.groupCallUpdate = Optional.fromNullable(groupCallUpdate); this.payment = Optional.fromNullable(payment); this.storyContext = Optional.fromNullable(storyContext); if (attachments != null && !attachments.isEmpty()) { this.attachments = Optional.of(attachments); @@ -236,6 +249,10 @@ public boolean isViewOnce() { return payment; } public Optional getStoryContext() { return storyContext; } public Optional getGroupId() { byte[] groupId = null; @@ -273,6 +290,7 @@ public boolean isViewOnce() { private RemoteDelete remoteDelete; private GroupCallUpdate groupCallUpdate; private Payment payment; private StoryContext storyContext; private Builder() {} @@ -400,14 +418,20 @@ public Builder withPayment(Payment payment) { return this; } public Builder withStoryContext(StoryContext storyContext) { this.storyContext = storyContext; return this; } public SignalServiceDataMessage build() { if (timestamp == 0) timestamp = System.currentTimeMillis(); return new SignalServiceDataMessage(timestamp, group, groupV2, attachments, body, endSession, expiresInSeconds, expirationUpdate, profileKey, profileKeyUpdate, quote, sharedContacts, previews, mentions, sticker, viewOnce, reaction, remoteDelete, groupCallUpdate, payment); payment, storyContext); } } @@ -651,4 +675,22 @@ public Payment(PaymentNotification paymentNotification) { return paymentNotification; } } public static class StoryContext { private final ACI authorAci; private final long sentTimestamp; public StoryContext(ACI authorAci, long sentTimestamp) { this.authorAci = authorAci; this.sentTimestamp = sentTimestamp; } public ACI getAuthorAci() { return authorAci; } public long getSentTimestamp() { return sentTimestamp; } } } 6 libsignal/service/src/main/proto/SignalService.proto [*] Show comments View file Edit file Delete file This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters @@ -248,6 +248,11 @@ message DataMessage { optional string eraId = 1; } message StoryContext { optional string authorUuid = 1; optional uint64 sentTimestamp = 2; } message Payment { message Address { @@ -320,6 +325,7 @@ message DataMessage { repeated BodyRange bodyRanges = 18; optional GroupCallUpdate groupCallUpdate = 19; optional Payment payment = 20; optional StoryContext storyContext = 21; } message NullMessage { Toggle all file notes Toggle all file annotations 0 comments on commit 8bc7d1b Please sign in to comment. * (c) 2022 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.