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

@@ -1525,7 +1525,7 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
@JvmStatic
fun from(event: CallEvent.Event?): Event? {
return when (event) {
null, CallEvent.Event.UNKNOWN_ACTION, CallEvent.Event.OBSERVED -> null
null, CallEvent.Event.UNKNOWN_EVENT, CallEvent.Event.OBSERVED -> null
CallEvent.Event.ACCEPTED -> ACCEPTED
CallEvent.Event.NOT_ACCEPTED -> NOT_ACCEPTED
CallEvent.Event.DELETE -> DELETE

View File

@@ -70,7 +70,7 @@ class CallLinkUpdateSendJob private constructor(
val callLinkUpdate = CallLinkUpdate(
rootKey = callLink.credentials.linkKeyBytes.toByteString(),
adminPassKey = callLink.credentials.adminPassBytes?.toByteString(),
adminPasskey = callLink.credentials.adminPassBytes?.toByteString(),
type = callLinkUpdateType
)

View File

@@ -34,7 +34,7 @@ class MultiDeviceCallLinkSyncJob private constructor(
.build(),
CallLinkUpdate(
rootKey = credentials.linkKeyBytes.toByteString(),
adminPassKey = credentials.adminPassBytes!!.toByteString()
adminPasskey = credentials.adminPassBytes!!.toByteString()
)
)

View File

@@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.jobs
import org.signal.core.util.isAbsent
import org.signal.core.util.logging.Log
import org.signal.libsignal.protocol.InvalidMessageException
import org.thoughtcrime.securesms.database.IdentityTable.VerifiedStatus
import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobmanager.Job
@@ -16,7 +15,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer
import org.whispersystems.signalservice.api.messages.multidevice.DeviceContact
import org.whispersystems.signalservice.api.messages.multidevice.DeviceContactsInputStream
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage.VerifiedState
import org.whispersystems.signalservice.api.push.SignalServiceAddress
import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException
import org.whispersystems.signalservice.api.util.AttachmentPointerUtil
@@ -103,42 +101,6 @@ class MultiDeviceContactSyncJob(parameters: Parameters, private val attachmentPo
}
}
if (contact.profileKey.isPresent) {
val profileKey = contact.profileKey.get()
recipients.setProfileKey(recipient.id, profileKey)
}
if (contact.verified.isPresent) {
val verifiedStatus: VerifiedStatus = when (contact.verified.get().verified) {
VerifiedState.VERIFIED -> VerifiedStatus.VERIFIED
VerifiedState.UNVERIFIED -> VerifiedStatus.UNVERIFIED
else -> VerifiedStatus.DEFAULT
}
if (recipient.serviceId.isPresent) {
AppDependencies.protocolStore.aci().identities().saveIdentityWithoutSideEffects(
recipient.id,
recipient.serviceId.get(),
contact.verified.get().identityKey,
verifiedStatus,
false,
contact.verified.get().timestamp,
true
)
} else {
Log.w(TAG, "Missing serviceId for ${recipient.id} -- cannot save identity!")
}
}
val threadRecord = threads.getThreadRecord(threads.getThreadIdFor(recipient.id))
if (threadRecord != null && contact.isArchived != threadRecord.isArchived) {
if (contact.isArchived) {
threads.archiveConversation(threadRecord.threadId)
} else {
threads.unarchiveConversation(threadRecord.threadId)
}
}
if (contact.avatar.isPresent) {
try {
AvatarHelper.setSyncAvatar(context, recipient.id, contact.avatar.get().inputStream)

View File

@@ -157,8 +157,6 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
return;
}
Optional<IdentityRecord> identityRecord = AppDependencies.getProtocolStore().aci().identities().getIdentityRecord(recipient.getId());
Optional<VerifiedMessage> verifiedMessage = getVerifiedMessage(recipient, identityRecord);
Map<RecipientId, Integer> inboxPositions = SignalDatabase.threads().getInboxPositions();
Set<RecipientId> archived = SignalDatabase.threads().getArchivedRecipients();
@@ -166,14 +164,10 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
recipient.getE164(),
Optional.ofNullable(recipient.isGroup() || recipient.isSystemContact() ? recipient.getDisplayName(context) : null),
getSystemAvatar(recipient.getContactUri()),
Optional.of(ChatColorsMapper.getMaterialColor(recipient.getChatColors()).serialize()),
verifiedMessage,
ProfileKeyUtil.profileKeyOptional(recipient.getProfileKey()),
recipient.getExpiresInSeconds() > 0 ? Optional.of(recipient.getExpiresInSeconds())
: Optional.empty(),
Optional.of(recipient.getExpireTimerVersion()),
Optional.ofNullable(inboxPositions.get(recipientId)),
archived.contains(recipientId)));
Optional.ofNullable(inboxPositions.get(recipientId))));
out.close();
updateUri = writeDetails.getUri();
@@ -185,7 +179,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
length,
false);
} catch(InvalidNumberException | InterruptedException e) {
} catch(InterruptedException e) {
Log.w(TAG, e);
} finally {
if (updateUri != null) {
@@ -222,10 +216,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
for (Recipient recipient : recipients) {
Optional<IdentityRecord> identity = AppDependencies.getProtocolStore().aci().identities().getIdentityRecord(recipient.getId());
Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity);
Optional<String> name = Optional.ofNullable(recipient.isSystemContact() ? recipient.getDisplayName(context) : recipient.getGroupName(context));
Optional<ProfileKey> profileKey = ProfileKeyUtil.profileKeyOptional(recipient.getProfileKey());
boolean blocked = recipient.isBlocked();
Optional<Integer> expireTimer = recipient.getExpiresInSeconds() > 0 ? Optional.of(recipient.getExpiresInSeconds()) : Optional.empty();
Optional<Integer> expireTimerVersion = Optional.of(recipient.getExpireTimerVersion());
Optional<Integer> inboxPosition = Optional.ofNullable(inboxPositions.get(recipient.getId()));
@@ -234,13 +225,9 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
recipient.getE164(),
name,
getSystemAvatar(recipient.getContactUri()),
Optional.of(ChatColorsMapper.getMaterialColor(recipient.getChatColors()).serialize()),
verified,
profileKey,
expireTimer,
expireTimerVersion,
inboxPosition,
archived.contains(recipient.getId())));
inboxPosition));
}
@@ -252,13 +239,9 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
Optional.of(SignalStore.account().getE164()),
Optional.empty(),
Optional.empty(),
Optional.of(ChatColorsMapper.getMaterialColor(self.getChatColors()).serialize()),
Optional.empty(),
ProfileKeyUtil.profileKeyOptionalOrThrow(self.getProfileKey()),
self.getExpiresInSeconds() > 0 ? Optional.of(self.getExpiresInSeconds()) : Optional.empty(),
Optional.of(self.getExpireTimerVersion()),
Optional.ofNullable(inboxPositions.get(self.getId())),
archived.contains(self.getId())));
Optional.ofNullable(inboxPositions.get(self.getId()))));
}
out.close();
@@ -271,7 +254,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
BlobProvider.getInstance().getStream(context, updateUri),
length,
true);
} catch(InvalidNumberException | InterruptedException e) {
} catch(InterruptedException e) {
Log.w(TAG, e);
} finally {
if (updateUri != null) {

View File

@@ -316,7 +316,7 @@ class MultiDeviceDeleteSyncJob private constructor(
DeleteForMe.AttachmentDelete(
conversation = conversation,
targetMessage = targetMessage,
uuid = it.uuid,
clientUuid = it.uuid,
fallbackDigest = it.digest,
fallbackPlaintextHash = it.plaintextHash
)

View File

@@ -81,11 +81,7 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob {
Optional.empty(),
Optional.empty(),
Optional.empty(),
profileKey,
Optional.empty(),
Optional.empty(),
Optional.empty(),
false));
Optional.empty()));
out.close();

View File

@@ -48,7 +48,7 @@ class RefreshCallLinkDetailsJob private constructor(
val manager: SignalCallLinkManager = AppDependencies.signalCallManager.callLinkManager
val credentials = CallLinkCredentials(
linkKeyBytes = callLinkUpdate.rootKey!!.toByteArray(),
adminPassBytes = callLinkUpdate.adminPassKey?.toByteArray()
adminPassBytes = callLinkUpdate.adminPasskey?.toByteArray()
)
when (val result = manager.readCallLink(credentials).safeBlockingGet()) {

View File

@@ -274,7 +274,7 @@ class IncomingMessageObserver(private val context: Application, private val sign
@VisibleForTesting
fun processEnvelope(bufferedProtocolStore: BufferedProtocolStore, envelope: Envelope, serverDeliveredTimestamp: Long): List<FollowUpOperation>? {
return when (envelope.type) {
Envelope.Type.RECEIPT -> {
Envelope.Type.SERVER_DELIVERY_RECEIPT -> {
processReceipt(envelope)
null
}

View File

@@ -197,9 +197,9 @@ object MessageDecryptor {
}
// TODO We can move this to the "message processing" stage once we give it access to the envelope. But for now it'll stay here.
if (envelope.reportingToken != null && envelope.reportingToken!!.size > 0) {
if (envelope.report_spam_token != null && envelope.report_spam_token!!.size > 0) {
val sender = RecipientId.from(cipherResult.metadata.sourceServiceId)
SignalDatabase.recipients.setReportingToken(sender, envelope.reportingToken!!.toByteArray())
SignalDatabase.recipients.setReportingToken(sender, envelope.report_spam_token!!.toByteArray())
}
Result.Success(envelope, serverDeliveredTimestamp, cipherResult.content, cipherResult.metadata, followUpOperations.toUnmodifiableList())

View File

@@ -157,7 +157,6 @@ object SyncMessageProcessor {
syncMessage.fetchLatest?.type != null -> handleSynchronizeFetchMessage(syncMessage.fetchLatest!!.type!!, envelope.timestamp!!)
syncMessage.messageRequestResponse != null -> handleSynchronizeMessageRequestResponse(syncMessage.messageRequestResponse!!, envelope.timestamp!!)
syncMessage.outgoingPayment != null -> handleSynchronizeOutgoingPayment(syncMessage.outgoingPayment!!, envelope.timestamp!!)
syncMessage.keys?.storageService != null -> handleSynchronizeKeys(syncMessage.keys!!.storageService!!, envelope.timestamp!!)
syncMessage.contacts != null -> handleSynchronizeContacts(syncMessage.contacts!!, envelope.timestamp!!)
syncMessage.callEvent != null -> handleSynchronizeCallEvent(syncMessage.callEvent!!, envelope.timestamp!!)
syncMessage.callLinkUpdate != null -> handleSynchronizeCallLink(syncMessage.callLinkUpdate!!, envelope.timestamp!!)
@@ -262,7 +261,7 @@ object SyncMessageProcessor {
private fun handlePniIdentityKeys(envelope: Envelope, sent: Sent) {
for (status in sent.unidentifiedStatus) {
if (status.destinationIdentityKey == null) {
if (status.destinationPniIdentityKey == null) {
continue
}
@@ -280,7 +279,7 @@ object SyncMessageProcessor {
try {
log(envelope.timestamp!!, "Saving identity from sent transcript for $pni")
val identityKey = IdentityKey(status.destinationIdentityKey!!.toByteArray())
val identityKey = IdentityKey(status.destinationPniIdentityKey!!.toByteArray())
AppDependencies.protocolStore.aci().identities().saveIdentity(address, identityKey)
} catch (e: InvalidKeyException) {
warn(envelope.timestamp!!, "Failed to deserialize identity key for $pni")
@@ -1262,7 +1261,7 @@ object SyncMessageProcessor {
}
private fun handleSynchronizeCallEvent(callEvent: SyncMessage.CallEvent, envelopeTimestamp: Long) {
if (callEvent.id == null) {
if (callEvent.callId == null) {
log(envelopeTimestamp, "Synchronize call event missing call id, ignoring. type: ${callEvent.type}")
return
}
@@ -1346,7 +1345,7 @@ object SyncMessageProcessor {
roomId,
CallLinkCredentials(
callLinkUpdate.rootKey!!.toByteArray(),
callLinkUpdate.adminPassKey?.toByteArray()
callLinkUpdate.adminPasskey?.toByteArray()
)
)
} else {
@@ -1357,7 +1356,7 @@ object SyncMessageProcessor {
roomId = roomId,
credentials = CallLinkCredentials(
linkKeyBytes = callLinkRootKey.keyBytes,
adminPassBytes = callLinkUpdate.adminPassKey?.toByteArray()
adminPassBytes = callLinkUpdate.adminPasskey?.toByteArray()
),
state = SignalCallLinkState(),
deletionTimestamp = 0L
@@ -1371,7 +1370,7 @@ object SyncMessageProcessor {
}
private fun handleSynchronizeOneToOneCallEvent(callEvent: SyncMessage.CallEvent, envelopeTimestamp: Long) {
val callId: Long = callEvent.id!!
val callId: Long = callEvent.callId!!
val timestamp: Long = callEvent.timestamp ?: 0L
val type: CallTable.Type? = CallTable.Type.from(callEvent.type)
val direction: CallTable.Direction? = CallTable.Direction.from(callEvent.direction)
@@ -1410,7 +1409,7 @@ object SyncMessageProcessor {
@Throws(BadGroupIdException::class)
private fun handleSynchronizeGroupOrAdHocCallEvent(callEvent: SyncMessage.CallEvent, envelopeTimestamp: Long) {
val callId: Long = callEvent.id!!
val callId: Long = callEvent.callId!!
val timestamp: Long = callEvent.timestamp ?: 0L
val type: CallTable.Type? = CallTable.Type.from(callEvent.type)
val direction: CallTable.Direction? = CallTable.Direction.from(callEvent.direction)
@@ -1491,11 +1490,11 @@ object SyncMessageProcessor {
}
} else {
when (event) {
CallTable.Event.DELETE -> SignalDatabase.calls.insertDeletedCallFromSyncEvent(callEvent.id!!, recipient.id, type, direction, timestamp)
CallTable.Event.ACCEPTED -> SignalDatabase.calls.insertAcceptedGroupCall(callEvent.id!!, recipient.id, direction, timestamp)
CallTable.Event.DELETE -> SignalDatabase.calls.insertDeletedCallFromSyncEvent(callEvent.callId!!, recipient.id, type, direction, timestamp)
CallTable.Event.ACCEPTED -> SignalDatabase.calls.insertAcceptedGroupCall(callEvent.callId!!, recipient.id, direction, timestamp)
CallTable.Event.NOT_ACCEPTED -> {
if (callEvent.direction == SyncMessage.CallEvent.Direction.INCOMING) {
SignalDatabase.calls.insertDeclinedGroupCall(callEvent.id!!, recipient.id, timestamp)
SignalDatabase.calls.insertDeclinedGroupCall(callEvent.callId!!, recipient.id, timestamp)
} else {
warn(envelopeTimestamp, "Invalid direction OUTGOING for event NOT_ACCEPTED for non-existing call")
}
@@ -1677,7 +1676,7 @@ object SyncMessageProcessor {
}
private fun SyncMessage.DeleteForMe.AttachmentDelete.toSyncAttachmentId(syncMessageId: MessageTable.SyncMessageId?, envelopeTimestamp: Long): AttachmentTable.SyncAttachmentId? {
val uuid = UuidUtil.fromByteStringOrNull(uuid)
val uuid = UuidUtil.fromByteStringOrNull(clientUuid)
val digest = fallbackDigest?.toByteArray()
val plaintextHash = fallbackPlaintextHash?.let { Base64.encodeWithPadding(it.toByteArray()) }

View File

@@ -61,12 +61,6 @@ public final class MessageGroupContext {
}
}
public MessageGroupContext(@NonNull GroupContext group) {
this.groupV1 = new GroupV1Properties(group);
this.groupV2 = null;
this.group = groupV1;
}
public MessageGroupContext(@NonNull DecryptedGroupV2Context group) {
this.groupV1 = null;
this.groupV2 = new GroupV2Properties(group);

View File

@@ -21,10 +21,10 @@ public final class MobileCoinPublicAddressProfileUtil {
byte[] signature = identityKeyPair.getPrivateKey().calculateSignature(publicAddressBytes);
return new PaymentAddress.Builder()
.mobileCoinAddress(new PaymentAddress.MobileCoinAddress.Builder()
.address(ByteString.of(publicAddressBytes))
.signature(ByteString.of(signature))
.build())
.mobileCoin(new PaymentAddress.MobileCoin.Builder()
.publicAddress(ByteString.of(publicAddressBytes))
.signature(ByteString.of(signature))
.build())
.build();
}
@@ -37,16 +37,16 @@ public final class MobileCoinPublicAddressProfileUtil {
@NonNull IdentityKey identityKey)
throws PaymentsAddressException
{
if (paymentAddress.mobileCoinAddress == null) {
if (paymentAddress.mobileCoin == null) {
throw new PaymentsAddressException(PaymentsAddressException.Code.NO_ADDRESS);
}
if (paymentAddress.mobileCoinAddress.address == null || paymentAddress.mobileCoinAddress.signature == null) {
if (paymentAddress.mobileCoin.publicAddress == null || paymentAddress.mobileCoin.signature == null) {
throw new PaymentsAddressException(PaymentsAddressException.Code.INVALID_ADDRESS_SIGNATURE);
}
byte[] bytes = paymentAddress.mobileCoinAddress.address.toByteArray();
byte[] signature = paymentAddress.mobileCoinAddress.signature.toByteArray();
byte[] bytes = paymentAddress.mobileCoin.publicAddress.toByteArray();
byte[] signature = paymentAddress.mobileCoin.signature.toByteArray();
if (signature.length != 64 || !identityKey.getPublicKey().verifySignature(bytes, signature)) {
throw new PaymentsAddressException(PaymentsAddressException.Code.INVALID_ADDRESS_SIGNATURE);

View File

@@ -83,7 +83,7 @@ object CallEventSyncMessageUtil {
return CallEvent(
conversationId = conversationId,
id = callId,
callId = callId,
timestamp = timestamp,
type = callType,
direction = if (isOutgoing) CallEvent.Direction.OUTGOING else CallEvent.Direction.INCOMING,