Add server message to group patch exception.

This commit is contained in:
Cody Henthorne
2025-07-22 09:35:02 -04:00
committed by Michelle Tang
parent eca75ca3fb
commit d1c02ac454
3 changed files with 32 additions and 2 deletions
@@ -0,0 +1,15 @@
/*
* Copyright 2025 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.whispersystems.signalservice.internal.push
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
/** Error response when attempting to patch group state. */
data class GroupPatchResponse @JsonCreator constructor(
@JsonProperty val code: Int?,
@JsonProperty val message: String?
)
@@ -35,7 +35,6 @@ import org.whispersystems.signalservice.api.messages.calls.CallingResponse;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.push.SignedPreKeyEntity;
import org.whispersystems.signalservice.api.push.exceptions.AlreadyVerifiedException;
import org.whispersystems.signalservice.api.remoteconfig.RemoteConfigResponse;
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
import org.whispersystems.signalservice.api.push.exceptions.ChallengeRequiredException;
import org.whispersystems.signalservice.api.push.exceptions.ConflictException;
@@ -66,6 +65,7 @@ import org.whispersystems.signalservice.api.push.exceptions.SubmitVerificationCo
import org.whispersystems.signalservice.api.push.exceptions.TokenNotAcceptedException;
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
import org.whispersystems.signalservice.api.registration.RestoreMethodBody;
import org.whispersystems.signalservice.api.remoteconfig.RemoteConfigResponse;
import org.whispersystems.signalservice.api.svr.Svr3Credentials;
import org.whispersystems.signalservice.api.util.CredentialsProvider;
import org.whispersystems.signalservice.api.util.Tls12SocketFactory;
@@ -1718,7 +1718,16 @@ public class PushServiceSocket {
throw new NonSuccessfulResponseCodeException(500, "Missing timestamp header");
}
if (responseCode == 400) throw new GroupPatchNotAcceptedException();
if (responseCode == 400) {
String message = null;
try {
message = JsonUtil.fromJson(body.string(), GroupPatchResponse.class).getMessage();
} catch (IOException e) {
Log.w(TAG, "Unable to parse group patch error", e);
}
throw message != null ? new GroupPatchNotAcceptedException(message) : new GroupPatchNotAcceptedException();
}
};
private static final ResponseCodeHandler GROUPS_V2_GET_JOIN_INFO_HANDLER = (responseCode, body, getHeader) -> {
@@ -2,8 +2,14 @@ package org.whispersystems.signalservice.internal.push.exceptions;
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
import javax.annotation.Nonnull;
public final class GroupPatchNotAcceptedException extends NonSuccessfulResponseCodeException {
public GroupPatchNotAcceptedException() {
super(400);
}
public GroupPatchNotAcceptedException(@Nonnull String message) {
super(400, message);
}
}