mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-08 03:08:33 +00:00
Group GET 404 and PUT 409 handling.
This commit is contained in:
parent
daf93c473b
commit
ffc7c13717
@ -0,0 +1,8 @@
|
|||||||
|
package org.thoughtcrime.securesms.groups;
|
||||||
|
|
||||||
|
public final class GroupAlreadyExistsException extends GroupChangeException {
|
||||||
|
|
||||||
|
public GroupAlreadyExistsException(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package org.thoughtcrime.securesms.groups;
|
||||||
|
|
||||||
|
public final class GroupDoesNotExistException extends GroupChangeException {
|
||||||
|
|
||||||
|
public GroupDoesNotExistException(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
}
|
||||||
|
}
|
@ -58,6 +58,7 @@ import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2Change
|
|||||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.ConflictException;
|
import org.whispersystems.signalservice.api.push.exceptions.ConflictException;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
import org.whispersystems.signalservice.internal.push.exceptions.GroupExistsException;
|
||||||
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
|
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
|
||||||
import org.whispersystems.signalservice.internal.push.exceptions.NotInGroupException;
|
import org.whispersystems.signalservice.internal.push.exceptions.NotInGroupException;
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ final class GroupManagerV2 {
|
|||||||
recipientAndThread.threadId,
|
recipientAndThread.threadId,
|
||||||
decryptedGroup.getMembersCount() - 1,
|
decryptedGroup.getMembersCount() - 1,
|
||||||
getPendingMemberRecipientIds(decryptedGroup.getPendingMembersList()));
|
getPendingMemberRecipientIds(decryptedGroup.getPendingMembersList()));
|
||||||
} catch (VerificationFailedException | InvalidGroupStateException e) {
|
} catch (VerificationFailedException | InvalidGroupStateException | GroupExistsException e) {
|
||||||
throw new GroupChangeFailedException(e);
|
throw new GroupChangeFailedException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.database.MessageDatabase;
|
|||||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context;
|
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context;
|
||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
|
import org.thoughtcrime.securesms.groups.GroupDoesNotExistException;
|
||||||
import org.thoughtcrime.securesms.groups.GroupId;
|
import org.thoughtcrime.securesms.groups.GroupId;
|
||||||
import org.thoughtcrime.securesms.groups.GroupMutation;
|
import org.thoughtcrime.securesms.groups.GroupMutation;
|
||||||
import org.thoughtcrime.securesms.groups.GroupNotAMemberException;
|
import org.thoughtcrime.securesms.groups.GroupNotAMemberException;
|
||||||
@ -48,6 +49,7 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2Api;
|
|||||||
import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
|
import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException;
|
import org.whispersystems.signalservice.api.groupsv2.NotAbleToApplyGroupV2ChangeException;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
import org.whispersystems.signalservice.internal.push.exceptions.GroupNotFoundException;
|
||||||
import org.whispersystems.signalservice.internal.push.exceptions.NotInGroupException;
|
import org.whispersystems.signalservice.internal.push.exceptions.NotInGroupException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -242,6 +244,21 @@ public final class GroupsV2StateProcessor {
|
|||||||
return new GroupUpdateResult(GroupState.GROUP_UPDATED, newLocalState);
|
return new GroupUpdateResult(GroupState.GROUP_UPDATED, newLocalState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
public DecryptedGroup getCurrentGroupStateFromServer()
|
||||||
|
throws IOException, GroupNotAMemberException, GroupDoesNotExistException
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return groupsV2Api.getGroup(groupSecretParams, groupsV2Authorization.getAuthorizationForToday(Recipient.self().requireUuid(), groupSecretParams));
|
||||||
|
} catch (GroupNotFoundException e) {
|
||||||
|
throw new GroupDoesNotExistException(e);
|
||||||
|
} catch (NotInGroupException e) {
|
||||||
|
throw new GroupNotAMemberException(e);
|
||||||
|
} catch (VerificationFailedException | InvalidGroupStateException e) {
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void insertGroupLeave() {
|
private void insertGroupLeave() {
|
||||||
if (!groupDatabase.isActive(groupId)) {
|
if (!groupDatabase.isActive(groupId)) {
|
||||||
Log.w(TAG, "Group has already been left.");
|
Log.w(TAG, "Group has already been left.");
|
||||||
@ -410,7 +427,7 @@ public final class GroupsV2StateProcessor {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
latestServerGroup = groupsV2Api.getGroup(groupSecretParams, groupsV2Authorization.getAuthorizationForToday(selfUuid, groupSecretParams));
|
latestServerGroup = groupsV2Api.getGroup(groupSecretParams, groupsV2Authorization.getAuthorizationForToday(selfUuid, groupSecretParams));
|
||||||
} catch (NotInGroupException e) {
|
} catch (NotInGroupException | GroupNotFoundException e) {
|
||||||
throw new GroupNotAMemberException(e);
|
throw new GroupNotAMemberException(e);
|
||||||
} catch (VerificationFailedException | InvalidGroupStateException e) {
|
} catch (VerificationFailedException | InvalidGroupStateException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
|
@ -76,6 +76,8 @@ import org.whispersystems.signalservice.internal.contacts.entities.KeyBackupRequ
|
|||||||
import org.whispersystems.signalservice.internal.contacts.entities.KeyBackupResponse;
|
import org.whispersystems.signalservice.internal.contacts.entities.KeyBackupResponse;
|
||||||
import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse;
|
import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse;
|
||||||
import org.whispersystems.signalservice.internal.push.exceptions.ForbiddenException;
|
import org.whispersystems.signalservice.internal.push.exceptions.ForbiddenException;
|
||||||
|
import org.whispersystems.signalservice.internal.push.exceptions.GroupExistsException;
|
||||||
|
import org.whispersystems.signalservice.internal.push.exceptions.GroupNotFoundException;
|
||||||
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
|
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
|
||||||
import org.whispersystems.signalservice.internal.push.exceptions.MismatchedDevicesException;
|
import org.whispersystems.signalservice.internal.push.exceptions.MismatchedDevicesException;
|
||||||
import org.whispersystems.signalservice.internal.push.exceptions.NotInGroupException;
|
import org.whispersystems.signalservice.internal.push.exceptions.NotInGroupException;
|
||||||
@ -1924,10 +1926,15 @@ public class PushServiceSocket {
|
|||||||
return JsonUtil.fromJson(response, CredentialResponse.class);
|
return JsonUtil.fromJson(response, CredentialResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ResponseCodeHandler GROUPS_V2_PUT_RESPONSE_HANDLER = NO_HANDLER;
|
private static final ResponseCodeHandler GROUPS_V2_PUT_RESPONSE_HANDLER = responseCode -> {
|
||||||
|
if (responseCode == 409) throw new GroupExistsException();
|
||||||
|
};;
|
||||||
private static final ResponseCodeHandler GROUPS_V2_GET_LOGS_HANDLER = NO_HANDLER;
|
private static final ResponseCodeHandler GROUPS_V2_GET_LOGS_HANDLER = NO_HANDLER;
|
||||||
private static final ResponseCodeHandler GROUPS_V2_GET_CURRENT_HANDLER = responseCode -> {
|
private static final ResponseCodeHandler GROUPS_V2_GET_CURRENT_HANDLER = responseCode -> {
|
||||||
if (responseCode == 403) throw new NotInGroupException();
|
switch (responseCode) {
|
||||||
|
case 403: throw new NotInGroupException();
|
||||||
|
case 404: throw new GroupNotFoundException();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
private static final ResponseCodeHandler GROUPS_V2_PATCH_RESPONSE_HANDLER = responseCode -> {
|
private static final ResponseCodeHandler GROUPS_V2_PATCH_RESPONSE_HANDLER = responseCode -> {
|
||||||
if (responseCode == 400) throw new GroupPatchNotAcceptedException();
|
if (responseCode == 400) throw new GroupPatchNotAcceptedException();
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package org.whispersystems.signalservice.internal.push.exceptions;
|
||||||
|
|
||||||
|
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||||
|
|
||||||
|
public final class GroupExistsException extends NonSuccessfulResponseCodeException {
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package org.whispersystems.signalservice.internal.push.exceptions;
|
||||||
|
|
||||||
|
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||||
|
|
||||||
|
public final class GroupNotFoundException extends NonSuccessfulResponseCodeException {
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user