Rename some protos.

This commit is contained in:
Greyson Parrelli
2023-07-13 13:08:07 -04:00
committed by Nicholas Tinsley
parent 1af50ba0f5
commit 8fc1065dd6
24 changed files with 177 additions and 184 deletions

View File

@@ -4529,7 +4529,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
}
fun setTimestampReadFromSyncMessageProto(readMessages: List<SyncMessage.Read>, proposedExpireStarted: Long, threadToLatestRead: MutableMap<Long, Long>): Collection<SyncMessageId> {
val reads: List<ReadMessage> = readMessages.map { r -> ReadMessage(ServiceId.parseOrThrow(r.senderUuid), r.timestamp) }
val reads: List<ReadMessage> = readMessages.map { r -> ReadMessage(ServiceId.parseOrThrow(r.senderAci), r.timestamp) }
return setTimestampReadFromSyncMessage(reads, proposedExpireStarted, threadToLatestRead)
}

View File

@@ -57,7 +57,7 @@ public class PushTable extends DatabaseTable {
} else {
ContentValues values = new ContentValues();
values.put(TYPE, envelope.getType());
values.put(SOURCE_UUID, envelope.getSourceUuid().orElse(null));
values.put(SOURCE_UUID, envelope.getSourceServiceId().orElse(null));
values.put(DEVICE_ID, envelope.getSourceDevice());
values.put(CONTENT, envelope.hasContent() ? Base64.encodeBytes(envelope.getContent()) : "");
values.put(TIMESTAMP, envelope.getTimestamp());
@@ -132,7 +132,7 @@ public class PushTable extends DatabaseTable {
String.valueOf(envelope.getSourceDevice()),
envelope.hasContent() ? Base64.encodeBytes(envelope.getContent()) : "",
String.valueOf(envelope.getTimestamp()),
String.valueOf(envelope.getSourceUuid().orElse(null)) };
String.valueOf(envelope.getSourceServiceId().orElse(null)) };
try (Cursor cursor = database.query(TABLE_NAME, null, query, args, null, null, null)) {

View File

@@ -87,7 +87,7 @@ data class SentStorySyncManifest(
fun fromRecipientsSet(recipients: List<SignalServiceProtos.SyncMessage.Sent.StoryMessageRecipient>): SentStorySyncManifest {
val entries = recipients.toSet().map { recipient ->
Entry(
recipientId = RecipientId.from(ServiceId.parseOrThrow(recipient.destinationUuid)),
recipientId = RecipientId.from(ServiceId.parseOrThrow(recipient.destinationServiceId)),
allowedToReply = recipient.isAllowedToReply,
distributionLists = recipient.distributionListIdsList.map { DistributionId.from(it) }
)

View File

@@ -130,8 +130,8 @@ class PushProcessMessageJobV2 private constructor(
requireNetwork = true
}
}
} else if (result.content.hasSyncMessage() && result.content.syncMessage.hasSent() && result.content.syncMessage.sent.hasDestinationUuid()) {
queueName = getQueueName(RecipientId.from(ServiceId.parseOrThrow(result.content.syncMessage.sent.destinationUuid)))
} else if (result.content.hasSyncMessage() && result.content.syncMessage.hasSent() && result.content.syncMessage.sent.hasDestinationServiceId()) {
queueName = getQueueName(RecipientId.from(ServiceId.parseOrThrow(result.content.syncMessage.sent.destinationServiceId)))
} else {
queueName = getQueueName(RecipientId.from(result.metadata.sourceServiceId))
}

View File

@@ -368,7 +368,7 @@ object DataMessageProcessor {
return null
}
val authorServiceId: ServiceId = ServiceId.parseOrThrow(message.storyContext.authorUuid)
val authorServiceId: ServiceId = ServiceId.parseOrThrow(message.storyContext.authorAci)
val sentTimestamp = message.storyContext.sentTimestamp
SignalDatabase.messages.beginTransaction()
@@ -459,7 +459,7 @@ object DataMessageProcessor {
val emoji: String = message.reaction.emoji
val isRemove: Boolean = message.reaction.remove
val targetAuthorServiceId: ServiceId = ServiceId.parseOrThrow(message.reaction.targetAuthorUuid)
val targetAuthorServiceId: ServiceId = ServiceId.parseOrThrow(message.reaction.targetAuthorAci)
val targetSentTimestamp = message.reaction.targetSentTimestamp
if (targetAuthorServiceId.isUnknown) {
@@ -668,7 +668,7 @@ object DataMessageProcessor {
): MessageId? {
log(envelope.timestamp, "Story reply.")
val authorServiceId: ServiceId = ServiceId.parseOrThrow(message.storyContext.authorUuid)
val authorServiceId: ServiceId = ServiceId.parseOrThrow(message.storyContext.authorAci)
val sentTimestamp = message.storyContext.sentTimestamp
SignalDatabase.messages.beginTransaction()
@@ -990,9 +990,9 @@ object DataMessageProcessor {
fun getMentions(mentionBodyRanges: List<BodyRange>): List<Mention> {
return mentionBodyRanges
.filter { it.hasMentionUuid() }
.filter { it.hasMentionAci() }
.mapNotNull {
val serviceId = ServiceId.parseOrNull(it.mentionUuid)
val serviceId = ServiceId.parseOrNull(it.mentionAci)
if (serviceId != null && !serviceId.isUnknown) {
val id = Recipient.externalPush(serviceId).id
@@ -1031,7 +1031,7 @@ object DataMessageProcessor {
return null
}
val authorId = Recipient.externalPush(ServiceId.parseOrThrow(quote.authorUuid)).id
val authorId = Recipient.externalPush(ServiceId.parseOrThrow(quote.authorAci)).id
var quotedMessage = SignalDatabase.messages.getMessageFor(quote.id, authorId) as? MediaMmsMessageRecord
if (quotedMessage != null && !quotedMessage.isRemoteDelete) {
@@ -1086,7 +1086,7 @@ object DataMessageProcessor {
quote.attachmentsList.mapNotNull { PointerAttachment.forPointer(it).orNull() },
getMentions(quote.bodyRangesList),
QuoteModel.Type.fromProto(quote.type),
quote.bodyRangesList.filterNot { it.hasMentionUuid() }.toBodyRangeList()
quote.bodyRangesList.filterNot { it.hasMentionAci() }.toBodyRangeList()
)
}

View File

@@ -328,12 +328,12 @@ class IncomingMessageObserver(private val context: Application) {
}
private fun processReceipt(envelope: SignalServiceProtos.Envelope) {
if (!UuidUtil.isUuid(envelope.sourceUuid)) {
if (!UuidUtil.isUuid(envelope.sourceServiceId)) {
Log.w(TAG, "Invalid envelope source UUID!")
return
}
val senderId = RecipientId.from(ServiceId.parseOrThrow(envelope.sourceUuid))
val senderId = RecipientId.from(ServiceId.parseOrThrow(envelope.sourceServiceId))
Log.i(TAG, "Received server receipt. Sender: $senderId, Device: ${envelope.sourceDevice}, Timestamp: ${envelope.timestamp}")
SignalDatabase.messages.incrementDeliveryReceiptCount(envelope.timestamp, senderId, System.currentTimeMillis())

View File

@@ -89,10 +89,10 @@ object MessageDecryptor {
val destination: ServiceId = envelope.getDestination(selfAci, selfPni)
if (destination == selfPni && envelope.hasSourceUuid()) {
if (destination == selfPni && envelope.hasSourceServiceId()) {
Log.i(TAG, "${logPrefix(envelope)} Received a message at our PNI. Marking as needing a PNI signature.")
val sourceServiceId = ServiceId.parseOrNull(envelope.sourceUuid)
val sourceServiceId = ServiceId.parseOrNull(envelope.sourceServiceId)
if (sourceServiceId != null) {
val sender = RecipientId.from(sourceServiceId)
@@ -102,7 +102,7 @@ object MessageDecryptor {
}
}
if (destination == selfPni && !envelope.hasSourceUuid()) {
if (destination == selfPni && !envelope.hasSourceServiceId()) {
Log.w(TAG, "${logPrefix(envelope)} Got a sealed sender message to our PNI? Invalid message, ignoring.")
return Result.Ignore(envelope, serverDeliveredTimestamp, emptyList())
}
@@ -352,7 +352,7 @@ object MessageDecryptor {
}
private fun logPrefix(envelope: Envelope): String {
return logPrefix(envelope.timestamp, envelope.sourceUuid ?: "<sealed>", envelope.sourceDevice)
return logPrefix(envelope.timestamp, envelope.sourceServiceId ?: "<sealed>", envelope.sourceDevice)
}
private fun logPrefix(envelope: Envelope, sender: ServiceId): String {
@@ -367,7 +367,7 @@ object MessageDecryptor {
return if (exception.sender != null) {
logPrefix(envelope.timestamp, exception.sender, exception.senderDevice)
} else {
logPrefix(envelope.timestamp, envelope.sourceUuid, envelope.sourceDevice)
logPrefix(envelope.timestamp, envelope.sourceServiceId, envelope.sourceDevice)
}
}
@@ -409,8 +409,8 @@ object MessageDecryptor {
private fun Envelope.getDestination(selfAci: ServiceId, selfPni: ServiceId): ServiceId {
return if (!FeatureFlags.phoneNumberPrivacy()) {
selfAci
} else if (this.hasDestinationUuid()) {
val serviceId = ServiceId.parseOrThrow(this.destinationUuid)
} else if (this.hasDestinationServiceId()) {
val serviceId = ServiceId.parseOrThrow(this.destinationServiceId)
if (serviceId == selfAci || serviceId == selfPni) {
serviceId
} else {

View File

@@ -131,14 +131,14 @@ object SignalServiceProtoUtil {
}
fun Sent.isUnidentified(serviceId: ServiceId?): Boolean {
return serviceId != null && unidentifiedStatusList.firstOrNull { ServiceId.parseOrNull(it.destinationUuid) == serviceId }?.unidentified ?: false
return serviceId != null && unidentifiedStatusList.firstOrNull { ServiceId.parseOrNull(it.destinationServiceId) == serviceId }?.unidentified ?: false
}
val Sent.serviceIdsToUnidentifiedStatus: Map<ServiceId, Boolean>
get() {
return unidentifiedStatusList
.mapNotNull { status ->
val serviceId = ServiceId.parseOrNull(status.destinationUuid)
val serviceId = ServiceId.parseOrNull(status.destinationServiceId)
if (serviceId != null) {
serviceId to status.unidentified
} else {

View File

@@ -71,7 +71,7 @@ object StoryMessageProcessor {
isStoryEmbed = true
),
serverGuid = envelope.serverGuid,
messageRanges = storyMessage.bodyRangesList.filterNot { it.hasMentionUuid() }.toBodyRangeList()
messageRanges = storyMessage.bodyRangesList.filterNot { it.hasMentionAci() }.toBodyRangeList()
)
insertResult = SignalDatabase.messages.insertSecureDecryptedMessageInbox(mediaMessage, -1).orNull()

View File

@@ -238,7 +238,7 @@ object SyncMessageProcessor {
return if (message.message.hasGroupContext) {
Recipient.externalPossiblyMigratedGroup(GroupId.v2(message.message.groupV2.groupMasterKey))
} else {
Recipient.externalPush(SignalServiceAddress(ServiceId.parseOrThrow(message.destinationUuid), message.destinationE164))
Recipient.externalPush(SignalServiceAddress(ServiceId.parseOrThrow(message.destinationServiceId), message.destinationE164))
}
}
@@ -265,7 +265,7 @@ object SyncMessageProcessor {
val toRecipient: Recipient = if (message.hasGroupContext) {
Recipient.externalPossiblyMigratedGroup(GroupId.v2(message.groupV2.groupMasterKey))
} else {
Recipient.externalPush(ServiceId.parseOrThrow(sent.destinationUuid))
Recipient.externalPush(ServiceId.parseOrThrow(sent.destinationServiceId))
}
if (message.isMediaMessage) {
handleSynchronizeSentEditMediaMessage(context, targetMessage, toRecipient, sent, message, envelope.timestamp)
@@ -287,7 +287,7 @@ object SyncMessageProcessor {
log(envelopeTimestamp, "Synchronize sent edit text message for message: ${targetMessage.id}")
val body = message.body ?: ""
val bodyRanges = message.bodyRangesList.filterNot { it.hasMentionUuid() }.toBodyRangeList()
val bodyRanges = message.bodyRangesList.filterNot { it.hasMentionAci() }.toBodyRangeList()
val threadId = SignalDatabase.threads.getOrCreateThreadIdFor(toRecipient)
val isGroup = toRecipient.isGroup
@@ -637,7 +637,7 @@ object SyncMessageProcessor {
try {
val reaction: DataMessage.Reaction = sent.message.reaction
val parentStoryId: ParentStoryId
val authorServiceId: ServiceId = ServiceId.parseOrThrow(sent.message.storyContext.authorUuid)
val authorServiceId: ServiceId = ServiceId.parseOrThrow(sent.message.storyContext.authorAci)
val sentTimestamp: Long = sent.message.storyContext.sentTimestamp
val recipient: Recipient = getSyncMessageDestination(sent)
var quoteModel: QuoteModel? = null
@@ -812,7 +812,7 @@ object SyncMessageProcessor {
val recipient = getSyncMessageDestination(sent)
val body = sent.message.body ?: ""
val expiresInMillis = sent.message.expireTimer.seconds.inWholeMilliseconds
val bodyRanges = sent.message.bodyRangesList.filterNot { it.hasMentionUuid() }.toBodyRangeList()
val bodyRanges = sent.message.bodyRangesList.filterNot { it.hasMentionAci() }.toBodyRangeList()
if (recipient.expiresInSeconds != sent.message.expireTimer) {
handleSynchronizeSentExpirationUpdate(sent, sideEffect = true)
@@ -923,7 +923,7 @@ object SyncMessageProcessor {
val records = viewedMessages
.mapNotNull { message ->
val author = Recipient.externalPush(ServiceId.parseOrThrow(message.senderUuid)).id
val author = Recipient.externalPush(ServiceId.parseOrThrow(message.senderAci)).id
SignalDatabase.messages.getMessageFor(message.timestamp, author)
}
@@ -950,7 +950,7 @@ object SyncMessageProcessor {
private fun handleSynchronizeViewOnceOpenMessage(context: Context, openMessage: ViewOnceOpen, envelopeTimestamp: Long, earlyMessageCacheEntry: EarlyMessageCacheEntry?) {
log(envelopeTimestamp, "Handling a view-once open for message: " + openMessage.timestamp)
val author: RecipientId = Recipient.externalPush(ServiceId.parseOrThrow(openMessage.senderUuid)).id
val author: RecipientId = Recipient.externalPush(ServiceId.parseOrThrow(openMessage.senderAci)).id
val timestamp: Long = openMessage.timestamp
val record: MessageRecord? = SignalDatabase.messages.getMessageFor(timestamp, author)
@@ -1019,7 +1019,7 @@ object SyncMessageProcessor {
}
private fun handleSynchronizeBlockedListMessage(blockMessage: Blocked) {
val addresses: List<SignalServiceAddress> = blockMessage.uuidsList.mapNotNull { SignalServiceAddress.fromRaw(it, null).orNull() }
val addresses: List<SignalServiceAddress> = blockMessage.acisList.mapNotNull { SignalServiceAddress.fromRaw(it, null).orNull() }
val groupIds: List<ByteArray> = blockMessage.groupIdsList.mapNotNull { it.toByteArray() }
SignalDatabase.recipients.applyBlockedUpdate(addresses, groupIds)
@@ -1039,8 +1039,8 @@ object SyncMessageProcessor {
private fun handleSynchronizeMessageRequestResponse(response: MessageRequestResponse, envelopeTimestamp: Long) {
log(envelopeTimestamp, "Synchronize message request response.")
val recipient: Recipient = if (response.hasThreadUuid()) {
Recipient.externalPush(ServiceId.parseOrThrow(response.threadUuid))
val recipient: Recipient = if (response.hasThreadAci()) {
Recipient.externalPush(ServiceId.parseOrThrow(response.threadAci))
} else if (response.hasGroupId()) {
val groupId: GroupId = GroupId.push(response.groupId)
Recipient.externalPossiblyMigratedGroup(groupId)
@@ -1083,7 +1083,7 @@ object SyncMessageProcessor {
return
}
var recipientId: RecipientId? = ServiceId.parseOrNull(outgoingPayment.recipientUuid)?.let { RecipientId.from(it) }
var recipientId: RecipientId? = ServiceId.parseOrNull(outgoingPayment.recipientServiceId)?.let { RecipientId.from(it) }
var timestamp = outgoingPayment.mobileCoin.ledgerBlockTimestamp
if (timestamp == 0L) {

View File

@@ -178,7 +178,7 @@ public final class IdentityUtil {
}
public static void processVerifiedMessage(Context context, SignalServiceProtos.Verified verified) throws InvalidKeyException {
SignalServiceAddress destination = new SignalServiceAddress(ServiceId.parseOrThrow(verified.getDestinationUuid()));
SignalServiceAddress destination = new SignalServiceAddress(ServiceId.parseOrThrow(verified.getDestinationAci()));
IdentityKey identityKey = new IdentityKey(verified.getIdentityKey().toByteArray(), 0);
VerifiedMessage.VerifiedState state;