Fix processing incoming group invites.

This commit is contained in:
Cody Henthorne
2024-07-16 15:45:22 -04:00
committed by GitHub
parent dd923629f6
commit 0e1df94b54
3 changed files with 17 additions and 9 deletions

View File

@@ -279,20 +279,27 @@ class GroupsV2StateProcessor private constructor(
): InternalUpdateResult {
var currentLocalState: DecryptedGroup? = groupRecord.map { it.requireV2GroupProperties().decryptedGroup }.orNull()
val latestRevisionOnly = targetRevision == LATEST && (currentLocalState == null || currentLocalState.revision == RESTORE_PLACEHOLDER_REVISION)
if (latestRevisionOnly) {
Log.i(TAG, "$logPrefix Latest revision or not a member, update to latest directly")
if (targetRevision == LATEST && (currentLocalState == null || currentLocalState.revision == RESTORE_PLACEHOLDER_REVISION)) {
Log.i(TAG, "$logPrefix Latest revision only, update to latest directly")
return updateToLatestViaServer(timestamp, currentLocalState, reconstructChange = false)
}
Log.i(TAG, "$logPrefix Paging from server targetRevision: ${if (targetRevision == LATEST) "latest" else targetRevision}")
val joinedAtRevision = when (val result = groupsApi.getGroupJoinedAt(groupsV2Authorization.getAuthorizationForToday(serviceIds, groupSecretParams))) {
is NetworkResult.Success -> result.result
else -> return InternalUpdateResult.from(result.getCause()!!)
val joinedAtResult = groupsApi.getGroupJoinedAt(groupsV2Authorization.getAuthorizationForToday(serviceIds, groupSecretParams))
if (joinedAtResult !is NetworkResult.Success) {
val joinedAtFailure = InternalUpdateResult.from(joinedAtResult.getCause()!!)
if (joinedAtFailure is InternalUpdateResult.NotAMember) {
Log.i(TAG, "$logPrefix Not a member, try to update to latest directly")
return updateToLatestViaServer(timestamp, currentLocalState, reconstructChange = currentLocalState != null)
} else {
return joinedAtFailure
}
}
val joinedAtRevision = joinedAtResult.result
val sendEndorsementExpiration = groupRecord.map { it.groupSendEndorsementExpiration }.orElse(0L)
var includeFirstState = currentLocalState == null ||

View File

@@ -450,6 +450,7 @@ class GroupsV2StateProcessorTest {
}
every { groupsV2API.getGroupJoinedAt(any()) } returns NetworkResult.StatusCodeError(NotInGroupException())
every { groupsV2API.getGroupAsResult(any(), any()) } returns NetworkResult.StatusCodeError(NotInGroupException())
val signedChange = DecryptedGroupChange(
revision = 2,
@@ -477,6 +478,7 @@ class GroupsV2StateProcessorTest {
}
every { groupsV2API.getGroupJoinedAt(any()) } returns NetworkResult.StatusCodeError(NotInGroupException())
every { groupsV2API.getGroupAsResult(any(), any()) } returns NetworkResult.StatusCodeError(NotInGroupException())
val signedChange = DecryptedGroupChange(
revision = 3,

View File

@@ -2798,7 +2798,6 @@ public class PushServiceSocket {
private static final ResponseCodeHandler GROUPS_V2_PUT_RESPONSE_HANDLER = (responseCode, body) -> {
if (responseCode == 409) throw new GroupExistsException();
};;
private static final ResponseCodeHandler GROUPS_V2_GET_LOGS_HANDLER = NO_HANDLER;
private static final ResponseCodeHandler GROUPS_V2_GET_CURRENT_HANDLER = (responseCode, body) -> {
switch (responseCode) {
case 403: throw new NotInGroupException();
@@ -2893,7 +2892,7 @@ public class PushServiceSocket {
"GET",
null,
headers,
GROUPS_V2_GET_LOGS_HANDLER))
GROUPS_V2_GET_CURRENT_HANDLER))
{
if (response.body() == null) {