Update to the standard SignalService.proto

This commit is contained in:
Greyson Parrelli
2025-02-12 10:33:03 -05:00
parent 95e0f7d571
commit 1b01532327
26 changed files with 593 additions and 777 deletions

View File

@@ -1391,7 +1391,7 @@ public class SignalServiceMessageSender {
unidentifiedDeliveryStatuses.add(new SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder()
.destinationServiceId(result.getAddress().getServiceId().toString())
.unidentified(false)
.destinationIdentityKey(identity)
.destinationPniIdentityKey(identity)
.build());
}
}
@@ -1665,10 +1665,6 @@ public class SignalServiceMessageSender {
SyncMessage.Builder syncMessage = createSyncMessageBuilder();
SyncMessage.Keys.Builder builder = new SyncMessage.Keys.Builder();
if (keysMessage.getStorageService() != null) {
builder.storageService(ByteString.of(keysMessage.getStorageService().serialize()));
}
if (keysMessage.getMaster() != null) {
builder.master(ByteString.of(keysMessage.getMaster().serialize()));
}

View File

@@ -17,25 +17,17 @@ public class DeviceContact {
private final Optional<String> e164;
private final Optional<String> name;
private final Optional<DeviceContactAvatar> avatar;
private final Optional<String> color;
private final Optional<VerifiedMessage> verified;
private final Optional<ProfileKey> profileKey;
private final Optional<Integer> expirationTimer;
private final Optional<Integer> expirationTimerVersion;
private final Optional<Integer> inboxPosition;
private final boolean archived;
public DeviceContact(Optional<ACI> aci,
Optional<String> e164,
Optional<String> name,
Optional<DeviceContactAvatar> avatar,
Optional<String> color,
Optional<VerifiedMessage> verified,
Optional<ProfileKey> profileKey,
Optional<Integer> expirationTimer,
Optional<Integer> expirationTimerVersion,
Optional<Integer> inboxPosition,
boolean archived)
Optional<Integer> inboxPosition)
{
if (aci.isEmpty() && e164.isEmpty()) {
throw new IllegalArgumentException("Must have either ACI or E164");
@@ -45,13 +37,9 @@ public class DeviceContact {
this.e164 = e164;
this.name = name;
this.avatar = avatar;
this.color = color;
this.verified = verified;
this.profileKey = profileKey;
this.expirationTimer = expirationTimer;
this.expirationTimerVersion = expirationTimerVersion;
this.inboxPosition = inboxPosition;
this.archived = archived;
}
public Optional<DeviceContactAvatar> getAvatar() {
@@ -70,18 +58,6 @@ public class DeviceContact {
return e164;
}
public Optional<String> getColor() {
return color;
}
public Optional<VerifiedMessage> getVerified() {
return verified;
}
public Optional<ProfileKey> getProfileKey() {
return profileKey;
}
public Optional<Integer> getExpirationTimer() {
return expirationTimer;
}
@@ -93,8 +69,4 @@ public class DeviceContact {
public Optional<Integer> getInboxPosition() {
return inboxPosition;
}
public boolean isArchived() {
return archived;
}
}

View File

@@ -50,13 +50,9 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
Optional<String> e164 = Optional.ofNullable(details.number);
Optional<String> name = Optional.ofNullable(details.name);
Optional<DeviceContactAvatar> avatar = Optional.empty();
Optional<String> color = details.color != null ? Optional.of(details.color) : Optional.empty();
Optional<VerifiedMessage> verified = Optional.empty();
Optional<ProfileKey> profileKey = Optional.empty();
Optional<Integer> expireTimer = Optional.empty();
Optional<Integer> expireTimerVersion = Optional.empty();
Optional<Integer> inboxPosition = Optional.empty();
boolean archived = false;
if (details.avatar != null && details.avatar.length != null) {
long avatarLength = details.avatar.length;
@@ -66,39 +62,6 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
avatar = Optional.of(new DeviceContactAvatar(avatarStream, avatarLength, avatarContentType));
}
if (details.verified != null) {
try {
if (!SignalServiceAddress.isValidAddress(details.verified.destinationAci, null)) {
throw new InvalidMessageException("Missing Verified address!");
}
IdentityKey identityKey = new IdentityKey(details.verified.identityKey.toByteArray(), 0);
SignalServiceAddress destination = new SignalServiceAddress(ServiceId.parseOrThrow(details.verified.destinationAci));
VerifiedMessage.VerifiedState state;
switch (details.verified.state) {
case VERIFIED: state = VerifiedMessage.VerifiedState.VERIFIED; break;
case UNVERIFIED:state = VerifiedMessage.VerifiedState.UNVERIFIED; break;
case DEFAULT: state = VerifiedMessage.VerifiedState.DEFAULT; break;
default: throw new InvalidMessageException("Unknown state: " + details.verified.state);
}
verified = Optional.of(new VerifiedMessage(destination, identityKey, state, System.currentTimeMillis()));
} catch (InvalidKeyException | InvalidMessageException e) {
Log.w(TAG, e);
verified = Optional.empty();
}
}
if (details.profileKey != null) {
try {
profileKey = Optional.ofNullable(new ProfileKey(details.profileKey.toByteArray()));
} catch (InvalidInputException e) {
Log.w(TAG, "Invalid profile key ignored", e);
}
}
if (details.expireTimer != null && details.expireTimer > 0) {
expireTimer = Optional.of(details.expireTimer);
}
@@ -111,9 +74,7 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
inboxPosition = Optional.of(details.inboxPosition);
}
archived = details.archived;
return new DeviceContact(aci, e164, name, avatar, color, verified, profileKey, expireTimer, expireTimerVersion, inboxPosition, archived);
return new DeviceContact(aci, e164, name, avatar, expireTimer, expireTimerVersion, inboxPosition);
}
}

View File

@@ -57,34 +57,6 @@ public class DeviceContactsOutputStream extends ChunkedOutputStream {
contactDetails.avatar(avatarBuilder.build());
}
if (contact.getColor().isPresent()) {
contactDetails.color(contact.getColor().get());
}
if (contact.getVerified().isPresent()) {
Verified.State state;
switch (contact.getVerified().get().getVerified()) {
case VERIFIED:
state = Verified.State.VERIFIED; break;
case UNVERIFIED:
state = Verified.State.UNVERIFIED; break;
default:
state = Verified.State.DEFAULT; break;
}
Verified.Builder verifiedBuilder = new Verified.Builder()
.identityKey(ByteString.of(contact.getVerified().get().getIdentityKey().serialize()))
.destinationAci(contact.getVerified().get().getDestination().getServiceId().toString())
.state(state);
contactDetails.verified(verifiedBuilder.build());
}
if (contact.getProfileKey().isPresent()) {
contactDetails.profileKey(ByteString.of(contact.getProfileKey().get().serialize()));
}
if (contact.getExpirationTimer().isPresent()) {
contactDetails.expireTimer(contact.getExpirationTimer().get());
}
@@ -93,8 +65,6 @@ public class DeviceContactsOutputStream extends ChunkedOutputStream {
contactDetails.inboxPosition(contact.getInboxPosition().get());
}
contactDetails.archived(contact.isArchived());
byte[] serializedContactDetails = contactDetails.build().encode();
writeVarint32(serializedContactDetails.length);

View File

@@ -40,11 +40,7 @@ public class RequestMessage {
return request.type == Request.Type.KEYS;
}
public boolean isPniIdentityRequest() {
return request.type == Request.Type.PNI_IDENTITY;
}
public boolean isUrgent() {
return isContactsRequest() || isKeysRequest() || isPniIdentityRequest();
return isContactsRequest() || isKeysRequest();
}
}

View File

@@ -28,7 +28,7 @@ public final class AttachmentPointerUtil {
pointer.height != null ? pointer.height : 0,
pointer.digest != null ? Optional.of(pointer.digest.toByteArray()) : Optional.empty(),
pointer.incrementalMac != null ? Optional.of(pointer.incrementalMac.toByteArray()) : Optional.empty(),
pointer.incrementalMacChunkSize != null ? pointer.incrementalMacChunkSize : 0,
pointer.chunkSize != null ? pointer.chunkSize : 0,
pointer.fileName != null ? Optional.of(pointer.fileName) : Optional.empty(),
((pointer.flags != null ? pointer.flags : 0) & FlagUtil.toBinaryFlag(AttachmentPointer.Flags.VOICE_MESSAGE.getValue())) != 0,
((pointer.flags != null ? pointer.flags : 0) & FlagUtil.toBinaryFlag(AttachmentPointer.Flags.BORDERLESS.getValue())) != 0,
@@ -36,7 +36,7 @@ public final class AttachmentPointerUtil {
pointer.caption != null ? Optional.of(pointer.caption) : Optional.empty(),
pointer.blurHash != null ? Optional.of(pointer.blurHash) : Optional.empty(),
pointer.uploadTimestamp != null ? pointer.uploadTimestamp : 0,
UuidUtil.fromByteStringOrNull(pointer.uuid));
UuidUtil.fromByteStringOrNull(pointer.clientUuid));
}
public static AttachmentPointer createAttachmentPointer(SignalServiceAttachmentPointer attachment) {
@@ -53,7 +53,7 @@ public final class AttachmentPointerUtil {
}
if (attachment.getIncrementalMacChunkSize() > 0) {
builder.incrementalMacChunkSize(attachment.getIncrementalMacChunkSize());
builder.chunkSize(attachment.getIncrementalMacChunkSize());
}
if (attachment.getRemoteId() instanceof SignalServiceAttachmentRemoteId.V2) {
@@ -105,7 +105,7 @@ public final class AttachmentPointerUtil {
}
if (attachment.getUuid() != null) {
builder.uuid(UuidUtil.toByteString(attachment.getUuid()));
builder.clientUuid(UuidUtil.toByteString(attachment.getUuid()));
}
return builder.build();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2020-2022 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
/**
* This file contains protos that were removed from SignalService.proto, but are still needed by our application,
* typically for serialization purposes.
*/
syntax = "proto2";
package signalservice;
option java_package = "org.whispersystems.signalservice.internal.push";
option java_outer_classname = "SignalServiceProtos";
import SignalService.proto;
message GroupContext {
enum Type {
UNKNOWN = 0;
UPDATE = 1;
DELIVER = 2;
QUIT = 3;
REQUEST_INFO = 4;
}
message Member {
reserved /* uuid */ 1; // removed
optional string e164 = 2;
}
optional bytes id = 1;
optional Type type = 2;
optional string name = 3;
repeated string membersE164 = 4;
repeated Member members = 6;
optional signalservice.AttachmentPointer avatar = 5;
}