Add kotlin/proto level message processing.

This commit is contained in:
Cody Henthorne
2023-03-30 11:45:13 -04:00
committed by Alex Hart
parent 28f27915c5
commit 2e45bd719a
43 changed files with 4505 additions and 84 deletions

View File

@@ -24,7 +24,7 @@ class AccountAttributes @JsonCreator constructor(
@JsonProperty val capabilities: Capabilities?,
@JsonProperty val name: String?,
@JsonProperty val pniRegistrationId: Int,
@JsonProperty val recoveryPassword: String?,
@JsonProperty val recoveryPassword: String?
) {
constructor(
signalingKey: String?,

View File

@@ -1339,7 +1339,7 @@ import javax.annotation.Nullable;
return new SignalServiceDataMessage.PaymentActivation(payment.getType());
}
private static @Nullable List<SharedContact> createSharedContacts(SignalServiceProtos.DataMessage content) throws InvalidMessageStructureException {
public static @Nullable List<SharedContact> createSharedContacts(SignalServiceProtos.DataMessage content) throws InvalidMessageStructureException {
if (content.getContactCount() <= 0) return null;
List<SharedContact> results = new LinkedList<>();

View File

@@ -11,6 +11,8 @@ import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
/**
* A wrapper around a UUID that represents an identifier for an account. Today, that is either an {@link ACI} or a {@link PNI}.
* However, that doesn't mean every {@link ServiceId} is an <em>instance</em> of one of those classes. In reality, we often
@@ -41,7 +43,7 @@ public class ServiceId {
return from(UuidUtil.parseOrThrow(raw));
}
public static ServiceId parseOrNull(String raw) {
public static @Nullable ServiceId parseOrNull(String raw) {
UUID uuid = UuidUtil.parseOrNull(raw);
return uuid != null ? from(uuid) : null;
}

View File

@@ -5,6 +5,8 @@ import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import javax.annotation.Nonnull;
import okio.Buffer;
import okio.BufferedSink;
import okio.ByteString;
@@ -117,6 +119,11 @@ public class NowhereBufferedSink implements BufferedSink {
return this;
}
@Override
public BufferedSink write(@Nonnull ByteString byteString, int i, int i1) throws IOException {
return this;
}
@Override
public void write(Buffer source, long byteCount) throws IOException {

View File

@@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
data class RegistrationSessionMetadataResponse(
val headers: RegistrationSessionMetadataHeaders,
val body: RegistrationSessionMetadataJson,
val state: RegistrationSessionState?,
val state: RegistrationSessionState?
)
data class RegistrationSessionMetadataHeaders(
@@ -23,7 +23,7 @@ data class RegistrationSessionMetadataJson(
@JsonProperty("nextVerificationAttempt") val nextVerificationAttempt: Int?,
@JsonProperty("allowedToRequestCode") val allowedToRequestCode: Boolean,
@JsonProperty("requestedInformation") val requestedInformation: List<String>,
@JsonProperty("verified") val verified: Boolean,
@JsonProperty("verified") val verified: Boolean
) {
fun pushChallengedRequired(): Boolean {
return requestedInformation.contains("pushChallenge")
@@ -35,5 +35,5 @@ data class RegistrationSessionMetadataJson(
}
data class RegistrationSessionState(
var pushChallengeTimedOut: Boolean,
var pushChallengeTimedOut: Boolean
)

View File

@@ -9,7 +9,7 @@ data class UpdateVerificationSessionRequestBody(
@JsonProperty val pushToken: String?,
@JsonProperty val pushChallenge: String?,
@JsonProperty val mcc: String?,
@JsonProperty val mnc: String?,
@JsonProperty val mnc: String?
) {
@JsonProperty
val pushTokenType: String? = if (pushToken != null) "fcm" else null

View File

@@ -8,7 +8,7 @@ data class VerificationSessionMetadataRequestBody(
@JsonProperty val number: String,
@JsonProperty val pushToken: String?,
@JsonProperty val mcc: String?,
@JsonProperty val mnc: String?,
@JsonProperty val mnc: String?
) {
@JsonProperty
val pushTokenType: String? = if (pushToken != null) "fcm" else null

View File

@@ -0,0 +1,27 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
syntax = "proto2";
package signalservice;
option java_package = "org.whispersystems.signalservice.api.crypto.protos";
message EnvelopeMetadata {
required bytes sourceServiceId = 1;
optional string sourceE164 = 2;
required int32 sourceDeviceId = 3;
required bool sealedSender = 4;
optional bytes groupId = 5;
required bytes destinationServiceId = 6;
}
message CompleteMessage {
required bytes envelope = 1;
required bytes content = 2;
required EnvelopeMetadata metadata = 3;
required int64 serverDeliveredTimestamp = 4;
}