Convert SignalService, Database, Group, Payment, and other remaining protos to wire.

This commit is contained in:
Cody Henthorne
2023-09-18 15:32:43 -04:00
committed by Alex Hart
parent a6b7d0bcc5
commit efbd5cab85
267 changed files with 7100 additions and 7214 deletions

View File

@@ -1,8 +1,8 @@
package org.thoughtcrime.securesms.util
import org.whispersystems.signalservice.api.crypto.EnvelopeMetadata
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.Envelope
import org.whispersystems.signalservice.internal.push.Content
import org.whispersystems.signalservice.internal.push.Envelope
/**
* The tuple of information needed to process a message. Used to in [EarlyMessageCache]

View File

@@ -21,7 +21,8 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import org.whispersystems.signalservice.internal.push.Content;
import org.whispersystems.signalservice.internal.push.GroupContextV2;
import java.io.IOException;
import java.util.List;
@@ -33,17 +34,17 @@ public final class GroupUtil {
private static final String TAG = Log.tag(GroupUtil.class);
public static @Nullable SignalServiceProtos.GroupContextV2 getGroupContextIfPresent(@NonNull SignalServiceProtos.Content content) {
if (content.hasDataMessage() && SignalServiceProtoUtil.INSTANCE.getHasGroupContext(content.getDataMessage())) {
return content.getDataMessage().getGroupV2();
} else if (content.hasSyncMessage() &&
content.getSyncMessage().hasSent() &&
content.getSyncMessage().getSent().hasMessage() &&
SignalServiceProtoUtil.INSTANCE.getHasGroupContext(content.getSyncMessage().getSent().getMessage()))
public static @Nullable GroupContextV2 getGroupContextIfPresent(@NonNull Content content) {
if (content.dataMessage != null && SignalServiceProtoUtil.INSTANCE.getHasGroupContext(content.dataMessage)) {
return content.dataMessage.groupV2;
} else if (content.syncMessage != null &&
content.syncMessage.sent != null &&
content.syncMessage.sent.message != null &&
SignalServiceProtoUtil.INSTANCE.getHasGroupContext(content.syncMessage.sent.message))
{
return content.getSyncMessage().getSent().getMessage().getGroupV2();
} else if (content.hasStoryMessage() && SignalServiceProtoUtil.INSTANCE.isValid(content.getStoryMessage().getGroup())) {
return content.getStoryMessage().getGroup();
return content.syncMessage.sent.message.groupV2;
} else if (content.storyMessage != null && SignalServiceProtoUtil.INSTANCE.isValid(content.storyMessage.group)) {
return content.storyMessage.group;
} else {
return null;
}

View File

@@ -40,7 +40,7 @@ import org.whispersystems.signalservice.api.SignalSessionLock;
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import org.whispersystems.signalservice.internal.push.Verified;
import java.util.List;
import java.util.Optional;
@@ -177,12 +177,12 @@ public final class IdentityUtil {
}
}
public static void processVerifiedMessage(Context context, SignalServiceProtos.Verified verified) throws InvalidKeyException {
SignalServiceAddress destination = new SignalServiceAddress(ServiceId.parseOrThrow(verified.getDestinationAci()));
IdentityKey identityKey = new IdentityKey(verified.getIdentityKey().toByteArray(), 0);
public static void processVerifiedMessage(Context context, Verified verified) throws InvalidKeyException {
SignalServiceAddress destination = new SignalServiceAddress(ServiceId.parseOrThrow(verified.destinationAci));
IdentityKey identityKey = new IdentityKey(verified.identityKey.toByteArray(), 0);
VerifiedMessage.VerifiedState state;
switch (verified.getState()) {
switch (verified.state) {
case DEFAULT:
state = VerifiedMessage.VerifiedState.DEFAULT;
break;

View File

@@ -54,7 +54,7 @@ fun MessageRecord.isBorderless(context: Context): Boolean {
}
fun MessageRecord.hasNoBubble(context: Context): Boolean =
hasSticker() || isBorderless(context) || (isTextOnly(context) && isJumbomoji(context) && (messageRanges?.rangesList?.isEmpty() ?: true))
hasSticker() || isBorderless(context) || (isTextOnly(context) && isJumbomoji(context) && (messageRanges?.ranges?.isEmpty() ?: true))
fun MessageRecord.hasOnlyThumbnail(context: Context): Boolean {
return hasThumbnail() &&

View File

@@ -46,7 +46,7 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.services.ProfileService;
import org.whispersystems.signalservice.api.util.StreamDetails;
import org.whispersystems.signalservice.internal.ServiceResponse;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import org.whispersystems.signalservice.internal.push.PaymentAddress;
import java.io.IOException;
import java.util.List;
@@ -170,12 +170,12 @@ public final class ProfileUtil {
}
try {
IdentityKey identityKey = new IdentityKey(Base64.decode(profileAndCredential.getProfile().getIdentityKey()), 0);
ProfileCipher profileCipher = new ProfileCipher(profileKey);
byte[] decrypted = profileCipher.decryptWithLength(encryptedPaymentsAddress);
SignalServiceProtos.PaymentAddress paymentAddress = SignalServiceProtos.PaymentAddress.parseFrom(decrypted);
byte[] bytes = MobileCoinPublicAddressProfileUtil.verifyPaymentsAddress(paymentAddress, identityKey);
MobileCoinPublicAddress mobileCoinPublicAddress = MobileCoinPublicAddress.fromBytes(bytes);
IdentityKey identityKey = new IdentityKey(Base64.decode(profileAndCredential.getProfile().getIdentityKey()), 0);
ProfileCipher profileCipher = new ProfileCipher(profileKey);
byte[] decrypted = profileCipher.decryptWithLength(encryptedPaymentsAddress);
PaymentAddress paymentAddress = PaymentAddress.ADAPTER.decode(decrypted);
byte[] bytes = MobileCoinPublicAddressProfileUtil.verifyPaymentsAddress(paymentAddress, identityKey);
MobileCoinPublicAddress mobileCoinPublicAddress = MobileCoinPublicAddress.fromBytes(bytes);
if (mobileCoinPublicAddress == null) {
throw new PaymentsAddressException(PaymentsAddressException.Code.INVALID_ADDRESS);
@@ -315,7 +315,7 @@ public final class ProfileUtil {
private static void uploadProfile(@NonNull ProfileName profileName,
@Nullable String about,
@Nullable String aboutEmoji,
@Nullable SignalServiceProtos.PaymentAddress paymentsAddress,
@Nullable PaymentAddress paymentsAddress,
@NonNull AvatarUploadParams avatar,
@NonNull List<Badge> badges)
throws IOException
@@ -354,7 +354,7 @@ public final class ProfileUtil {
ApplicationDependencies.getJobManager().add(new RefreshOwnProfileJob());
}
private static @Nullable SignalServiceProtos.PaymentAddress getSelfPaymentsAddressProtobuf() {
private static @Nullable PaymentAddress getSelfPaymentsAddressProtobuf() {
if (!SignalStore.paymentsValues().mobileCoinPaymentsEnabled()) {
return null;
} else {