mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-27 09:50:39 +00:00
Handle ServerRejectedException.
Handle an exception that indicates we should halt retries.
This commit is contained in:
@@ -26,6 +26,7 @@ import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NotFoundException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||
import org.whispersystems.signalservice.internal.push.AttachmentV2UploadAttributes;
|
||||
@@ -200,6 +201,8 @@ public class SignalServiceMessagePipe {
|
||||
return FutureTransformers.map(response, value -> {
|
||||
if (value.getStatus() == 404) {
|
||||
throw new UnregisteredUserException(list.getDestination(), new NotFoundException("not found"));
|
||||
} else if (value.getStatus() == 508) {
|
||||
throw new ServerRejectedException();
|
||||
} else if (value.getStatus() < 200 || value.getStatus() >= 300) {
|
||||
throw new IOException("Non-successful response: " + value.getStatus());
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
|
||||
@@ -1312,6 +1313,9 @@ public class SignalServiceMessageSender {
|
||||
} else if (e.getCause() instanceof PushNetworkException) {
|
||||
Log.w(TAG, e);
|
||||
results.add(SendMessageResult.networkFailure(recipient));
|
||||
} else if (e.getCause() instanceof ServerRejectedException) {
|
||||
Log.w(TAG, e);
|
||||
throw ((ServerRejectedException) e.getCause());
|
||||
} else {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
@@ -0,0 +1,7 @@
|
||||
package org.whispersystems.signalservice.api.push.exceptions;
|
||||
|
||||
/**
|
||||
* Indicates the server has rejected the request and we should stop retrying.
|
||||
*/
|
||||
public class ServerRejectedException extends NonSuccessfulResponseCodeException {
|
||||
}
|
@@ -63,6 +63,7 @@ import org.whispersystems.signalservice.api.push.exceptions.RangeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.RateLimitException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.RemoteAttestationResponseExpiredException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ResumeLocationInvalidException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.ServerRejectedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UsernameMalformedException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UsernameTakenException;
|
||||
@@ -1434,6 +1435,9 @@ public class PushServiceSocket {
|
||||
basicStorageCredentials);
|
||||
case 499:
|
||||
throw new DeprecatedVersionException();
|
||||
|
||||
case 508:
|
||||
throw new ServerRejectedException();
|
||||
}
|
||||
|
||||
if (responseCode != 200 && responseCode != 204) {
|
||||
|
Reference in New Issue
Block a user