kopia lustrzana https://github.com/ryukoposting/Signal-Android
Drop messages that have a story context.
rodzic
4dae424a5c
commit
8bc7d1b7f5
|
@ -259,6 +259,7 @@ public final class MessageContentProcessor {
|
||||||
else if (message.getReaction().isPresent()) messageId = handleReaction(content, message, senderRecipient);
|
else if (message.getReaction().isPresent()) messageId = handleReaction(content, message, senderRecipient);
|
||||||
else if (message.getRemoteDelete().isPresent()) messageId = handleRemoteDelete(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.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 (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 (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);
|
else if (Build.VERSION.SDK_INT > 19 && message.getGroupCallUpdate().isPresent()) handleGroupCallUpdateMessage(content, message, groupId, senderRecipient);
|
||||||
|
@ -1256,6 +1257,10 @@ public final class MessageContentProcessor {
|
||||||
messageNotifier.updateNotification(context);
|
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,
|
private @Nullable MessageId handleMediaMessage(@NonNull SignalServiceContent content,
|
||||||
@NonNull SignalServiceDataMessage message,
|
@NonNull SignalServiceDataMessage message,
|
||||||
@NonNull Optional<Long> smsMessageId,
|
@NonNull Optional<Long> smsMessageId,
|
||||||
|
|
|
@ -901,6 +901,14 @@ public class SignalServiceMessageSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
builder.setTimestamp(message.getTimestamp());
|
||||||
|
|
||||||
return enforceMaxContentSize(container.setDataMessage(builder).build());
|
return enforceMaxContentSize(container.setDataMessage(builder).build());
|
||||||
|
|
|
@ -529,6 +529,7 @@ public final class SignalServiceContent {
|
||||||
SignalServiceDataMessage.Reaction reaction = createReaction(content);
|
SignalServiceDataMessage.Reaction reaction = createReaction(content);
|
||||||
SignalServiceDataMessage.RemoteDelete remoteDelete = createRemoteDelete(content);
|
SignalServiceDataMessage.RemoteDelete remoteDelete = createRemoteDelete(content);
|
||||||
SignalServiceDataMessage.GroupCallUpdate groupCallUpdate = createGroupCallUpdate(content);
|
SignalServiceDataMessage.GroupCallUpdate groupCallUpdate = createGroupCallUpdate(content);
|
||||||
|
SignalServiceDataMessage.StoryContext storyContext = createStoryContext(content);
|
||||||
|
|
||||||
if (content.getRequiredProtocolVersion() > SignalServiceProtos.DataMessage.ProtocolVersion.CURRENT_VALUE) {
|
if (content.getRequiredProtocolVersion() > SignalServiceProtos.DataMessage.ProtocolVersion.CURRENT_VALUE) {
|
||||||
throw new UnsupportedDataMessageProtocolVersionException(SignalServiceProtos.DataMessage.ProtocolVersion.CURRENT_VALUE,
|
throw new UnsupportedDataMessageProtocolVersionException(SignalServiceProtos.DataMessage.ProtocolVersion.CURRENT_VALUE,
|
||||||
|
@ -577,7 +578,8 @@ public final class SignalServiceContent {
|
||||||
reaction,
|
reaction,
|
||||||
remoteDelete,
|
remoteDelete,
|
||||||
groupCallUpdate,
|
groupCallUpdate,
|
||||||
payment);
|
payment,
|
||||||
|
storyContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SignalServiceSyncMessage createSynchronizeMessage(SignalServiceMetadata metadata,
|
private static SignalServiceSyncMessage createSynchronizeMessage(SignalServiceMetadata metadata,
|
||||||
|
@ -1036,6 +1038,20 @@ public final class SignalServiceContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
private static SignalServiceDataMessage.PaymentNotification createPaymentNotification(SignalServiceProtos.DataMessage.Payment content)
|
||||||
throws InvalidMessageStructureException
|
throws InvalidMessageStructureException
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.whispersystems.signalservice.api.util.OptionalUtil;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a decrypted Signal Service data message.
|
* Represents a decrypted Signal Service data message.
|
||||||
|
@ -42,6 +41,7 @@ public class SignalServiceDataMessage {
|
||||||
private final Optional<RemoteDelete> remoteDelete;
|
private final Optional<RemoteDelete> remoteDelete;
|
||||||
private final Optional<GroupCallUpdate> groupCallUpdate;
|
private final Optional<GroupCallUpdate> groupCallUpdate;
|
||||||
private final Optional<Payment> payment;
|
private final Optional<Payment> payment;
|
||||||
|
private final Optional<StoryContext> storyContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a SignalServiceDataMessage.
|
* Construct a SignalServiceDataMessage.
|
||||||
|
@ -55,14 +55,26 @@ public class SignalServiceDataMessage {
|
||||||
* @param expiresInSeconds Number of seconds in which the message should disappear after being seen.
|
* @param expiresInSeconds Number of seconds in which the message should disappear after being seen.
|
||||||
*/
|
*/
|
||||||
SignalServiceDataMessage(long timestamp,
|
SignalServiceDataMessage(long timestamp,
|
||||||
SignalServiceGroup group, SignalServiceGroupV2 groupV2,
|
SignalServiceGroup group,
|
||||||
|
SignalServiceGroupV2 groupV2,
|
||||||
List<SignalServiceAttachment> attachments,
|
List<SignalServiceAttachment> attachments,
|
||||||
String body, boolean endSession, int expiresInSeconds,
|
String body,
|
||||||
boolean expirationUpdate, byte[] profileKey, boolean profileKeyUpdate,
|
boolean endSession,
|
||||||
Quote quote, List<SharedContact> sharedContacts, List<Preview> previews,
|
int expiresInSeconds,
|
||||||
List<Mention> mentions, Sticker sticker, boolean viewOnce, Reaction reaction, RemoteDelete remoteDelete,
|
boolean expirationUpdate,
|
||||||
|
byte[] profileKey,
|
||||||
|
boolean profileKeyUpdate,
|
||||||
|
Quote quote,
|
||||||
|
List<SharedContact> sharedContacts,
|
||||||
|
List<Preview> previews,
|
||||||
|
List<Mention> mentions,
|
||||||
|
Sticker sticker,
|
||||||
|
boolean viewOnce,
|
||||||
|
Reaction reaction,
|
||||||
|
RemoteDelete remoteDelete,
|
||||||
GroupCallUpdate groupCallUpdate,
|
GroupCallUpdate groupCallUpdate,
|
||||||
Payment payment)
|
Payment payment,
|
||||||
|
StoryContext storyContext)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
this.group = SignalServiceGroupContext.createOptional(group, groupV2);
|
this.group = SignalServiceGroupContext.createOptional(group, groupV2);
|
||||||
|
@ -84,6 +96,7 @@ public class SignalServiceDataMessage {
|
||||||
this.remoteDelete = Optional.fromNullable(remoteDelete);
|
this.remoteDelete = Optional.fromNullable(remoteDelete);
|
||||||
this.groupCallUpdate = Optional.fromNullable(groupCallUpdate);
|
this.groupCallUpdate = Optional.fromNullable(groupCallUpdate);
|
||||||
this.payment = Optional.fromNullable(payment);
|
this.payment = Optional.fromNullable(payment);
|
||||||
|
this.storyContext = Optional.fromNullable(storyContext);
|
||||||
|
|
||||||
if (attachments != null && !attachments.isEmpty()) {
|
if (attachments != null && !attachments.isEmpty()) {
|
||||||
this.attachments = Optional.of(attachments);
|
this.attachments = Optional.of(attachments);
|
||||||
|
@ -236,6 +249,10 @@ public class SignalServiceDataMessage {
|
||||||
return payment;
|
return payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<StoryContext> getStoryContext() {
|
||||||
|
return storyContext;
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<byte[]> getGroupId() {
|
public Optional<byte[]> getGroupId() {
|
||||||
byte[] groupId = null;
|
byte[] groupId = null;
|
||||||
|
|
||||||
|
@ -273,6 +290,7 @@ public class SignalServiceDataMessage {
|
||||||
private RemoteDelete remoteDelete;
|
private RemoteDelete remoteDelete;
|
||||||
private GroupCallUpdate groupCallUpdate;
|
private GroupCallUpdate groupCallUpdate;
|
||||||
private Payment payment;
|
private Payment payment;
|
||||||
|
private StoryContext storyContext;
|
||||||
|
|
||||||
private Builder() {}
|
private Builder() {}
|
||||||
|
|
||||||
|
@ -400,6 +418,11 @@ public class SignalServiceDataMessage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder withStoryContext(StoryContext storyContext) {
|
||||||
|
this.storyContext = storyContext;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public SignalServiceDataMessage build() {
|
public SignalServiceDataMessage build() {
|
||||||
if (timestamp == 0) timestamp = System.currentTimeMillis();
|
if (timestamp == 0) timestamp = System.currentTimeMillis();
|
||||||
return new SignalServiceDataMessage(timestamp, group, groupV2, attachments, body, endSession,
|
return new SignalServiceDataMessage(timestamp, group, groupV2, attachments, body, endSession,
|
||||||
|
@ -407,7 +430,8 @@ public class SignalServiceDataMessage {
|
||||||
profileKeyUpdate, quote, sharedContacts, previews,
|
profileKeyUpdate, quote, sharedContacts, previews,
|
||||||
mentions, sticker, viewOnce, reaction, remoteDelete,
|
mentions, sticker, viewOnce, reaction, remoteDelete,
|
||||||
groupCallUpdate,
|
groupCallUpdate,
|
||||||
payment);
|
payment,
|
||||||
|
storyContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,4 +675,22 @@ public class SignalServiceDataMessage {
|
||||||
return 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,6 +248,11 @@ message DataMessage {
|
||||||
optional string eraId = 1;
|
optional string eraId = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message StoryContext {
|
||||||
|
optional string authorUuid = 1;
|
||||||
|
optional uint64 sentTimestamp = 2;
|
||||||
|
}
|
||||||
|
|
||||||
message Payment {
|
message Payment {
|
||||||
|
|
||||||
message Address {
|
message Address {
|
||||||
|
@ -320,6 +325,7 @@ message DataMessage {
|
||||||
repeated BodyRange bodyRanges = 18;
|
repeated BodyRange bodyRanges = 18;
|
||||||
optional GroupCallUpdate groupCallUpdate = 19;
|
optional GroupCallUpdate groupCallUpdate = 19;
|
||||||
optional Payment payment = 20;
|
optional Payment payment = 20;
|
||||||
|
optional StoryContext storyContext = 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
message NullMessage {
|
message NullMessage {
|
||||||
|
|
Ładowanie…
Reference in New Issue