mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-01 06:03:18 +01:00
Add Delete for Me sync support.
This commit is contained in:
@@ -135,7 +135,6 @@ import org.whispersystems.util.ByteArrayUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -766,8 +765,15 @@ public class SignalServiceMessageSender {
|
||||
throw new IOException("Unsupported sync message!");
|
||||
}
|
||||
|
||||
long timestamp = message.getSent().isPresent() ? message.getSent().get().getTimestamp()
|
||||
: System.currentTimeMillis();
|
||||
Optional<Long> timestamp = message.getSent().map(SentTranscriptMessage::getTimestamp);
|
||||
|
||||
return sendSyncMessage(content, urgent, timestamp);
|
||||
}
|
||||
|
||||
public @Nonnull SendMessageResult sendSyncMessage(Content content, boolean urgent, Optional<Long> sent)
|
||||
throws IOException, UntrustedIdentityException
|
||||
{
|
||||
long timestamp = sent.orElseGet(System::currentTimeMillis);
|
||||
|
||||
EnvelopeContent envelopeContent = EnvelopeContent.encrypted(content, ContentHint.IMPLICIT, Optional.empty());
|
||||
|
||||
@@ -908,7 +914,7 @@ public class SignalServiceMessageSender {
|
||||
throws IOException, UntrustedIdentityException
|
||||
{
|
||||
byte[] nullMessageBody = new DataMessage.Builder()
|
||||
.body(Base64.encodeWithPadding(Util.getRandomLengthBytes(140)))
|
||||
.body(Base64.encodeWithPadding(Util.getRandomLengthSecretBytes(140)))
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
@@ -938,7 +944,7 @@ public class SignalServiceMessageSender {
|
||||
throws UntrustedIdentityException, IOException
|
||||
{
|
||||
byte[] nullMessageBody = new DataMessage.Builder()
|
||||
.body(Base64.encodeWithPadding(Util.getRandomLengthBytes(140)))
|
||||
.body(Base64.encodeWithPadding(Util.getRandomLengthSecretBytes(140)))
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
@@ -1763,9 +1769,7 @@ public class SignalServiceMessageSender {
|
||||
}
|
||||
|
||||
private SyncMessage.Builder createSyncMessageBuilder() {
|
||||
SecureRandom random = new SecureRandom();
|
||||
byte[] padding = Util.getRandomLengthBytes(512);
|
||||
random.nextBytes(padding);
|
||||
byte[] padding = Util.getRandomLengthSecretBytes(512);
|
||||
|
||||
SyncMessage.Builder builder = new SyncMessage.Builder();
|
||||
builder.padding(ByteString.of(padding));
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Util {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public static byte[] getRandomLengthBytes(int maxSize) {
|
||||
public static byte[] getRandomLengthSecretBytes(int maxSize) {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] result = new byte[secureRandom.nextInt(maxSize) + 1];
|
||||
secureRandom.nextBytes(result);
|
||||
|
||||
@@ -653,6 +653,43 @@ message SyncMessage {
|
||||
optional uint64 callId = 4;
|
||||
}
|
||||
|
||||
message DeleteForMe {
|
||||
message ConversationIdentifier {
|
||||
oneof identifier {
|
||||
string threadAci = 1;
|
||||
bytes threadGroupId = 2;
|
||||
string threadE164 = 3;
|
||||
}
|
||||
}
|
||||
|
||||
message AddressableMessage {
|
||||
oneof author {
|
||||
string authorAci = 1;
|
||||
string authorE164 = 2;
|
||||
}
|
||||
optional uint64 sentTimestamp = 3;
|
||||
}
|
||||
|
||||
message MessageDeletes {
|
||||
optional ConversationIdentifier conversation = 1;
|
||||
repeated AddressableMessage messages = 2;
|
||||
}
|
||||
|
||||
message ConversationDelete {
|
||||
optional ConversationIdentifier conversation = 1;
|
||||
repeated AddressableMessage mostRecentMessages = 2;
|
||||
optional bool isFullDelete = 3;
|
||||
}
|
||||
|
||||
message LocalOnlyConversationDelete {
|
||||
optional ConversationIdentifier conversation = 1;
|
||||
}
|
||||
|
||||
repeated MessageDeletes messageDeletes = 1;
|
||||
repeated ConversationDelete conversationDeletes = 2;
|
||||
repeated LocalOnlyConversationDelete localOnlyConversationDeletes = 3;
|
||||
}
|
||||
|
||||
optional Sent sent = 1;
|
||||
optional Contacts contacts = 2;
|
||||
reserved /*groups*/ 3;
|
||||
@@ -674,6 +711,7 @@ message SyncMessage {
|
||||
optional CallEvent callEvent = 19;
|
||||
optional CallLinkUpdate callLinkUpdate = 20;
|
||||
optional CallLogEvent callLogEvent = 21;
|
||||
optional DeleteForMe deleteForMe = 22;
|
||||
}
|
||||
|
||||
message AttachmentPointer {
|
||||
|
||||
Reference in New Issue
Block a user