Groups: Continue processing group if endorsements are invalid
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
2ba9afb7cf
commit
7027bca293
1 changed files with 96 additions and 58 deletions
42
ts/groups.ts
42
ts/groups.ts
|
@ -1593,6 +1593,7 @@ export async function modifyGroupV2({
|
|||
|
||||
// If we are no longer a member - endorsement won't be present
|
||||
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||
try {
|
||||
log.info(`modifyGroupV2/${logId}: Saving group endorsements`);
|
||||
|
||||
const groupEndorsementData = decodeGroupSendEndorsementResponse({
|
||||
|
@ -1602,7 +1603,14 @@ export async function modifyGroupV2({
|
|||
groupMembersV2: membersV2,
|
||||
});
|
||||
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
await DataWriter.replaceAllEndorsementsForGroup(
|
||||
groupEndorsementData
|
||||
);
|
||||
} catch (error) {
|
||||
log.warn(
|
||||
`modifyGroupV2/${logId}: Problem saving group endorsements ${Errors.toLogFormat(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1912,6 +1920,7 @@ export async function createGroupV2(
|
|||
'missing groupSendEndorsementResponse'
|
||||
);
|
||||
|
||||
try {
|
||||
const groupEndorsementData = decodeGroupSendEndorsementResponse({
|
||||
groupId,
|
||||
groupSendEndorsementResponse,
|
||||
|
@ -1920,6 +1929,11 @@ export async function createGroupV2(
|
|||
});
|
||||
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
} catch (error) {
|
||||
log.warn(
|
||||
`createGroupV2/${logId}: Problem saving group endorsements ${Errors.toLogFormat(error)}`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (!(error instanceof HTTPError)) {
|
||||
throw error;
|
||||
|
@ -2430,7 +2444,7 @@ export async function initiateMigrationToGroupV2(
|
|||
let groupSendEndorsementResponse: Uint8Array | null | undefined;
|
||||
try {
|
||||
const groupResponse = await makeRequestWithCredentials({
|
||||
logId: `createGroup/${logId}`,
|
||||
logId: `initiateMigrationToGroupV2/${logId}`,
|
||||
publicParams,
|
||||
secretParams,
|
||||
request: (sender, options) => sender.createGroup(groupProto, options),
|
||||
|
@ -2485,6 +2499,7 @@ export async function initiateMigrationToGroupV2(
|
|||
'missing groupSendEndorsementResponse'
|
||||
);
|
||||
|
||||
try {
|
||||
const groupEndorsementData = decodeGroupSendEndorsementResponse({
|
||||
groupId,
|
||||
groupSendEndorsementResponse,
|
||||
|
@ -2493,6 +2508,11 @@ export async function initiateMigrationToGroupV2(
|
|||
});
|
||||
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
} catch (error) {
|
||||
log.warn(
|
||||
`initiateMigrationToGroupV2/${logId}: Problem saving group endorsements ${Errors.toLogFormat(error)}`
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
const logId = conversation.idForLogging();
|
||||
|
@ -2969,6 +2989,7 @@ export async function respondToGroupV2Migration({
|
|||
});
|
||||
|
||||
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||
try {
|
||||
const { membersV2 } = conversation.attributes;
|
||||
strictAssert(membersV2, 'missing membersV2');
|
||||
|
||||
|
@ -2980,6 +3001,11 @@ export async function respondToGroupV2Migration({
|
|||
});
|
||||
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
} catch (error) {
|
||||
log.warn(
|
||||
`respondToGroupV2Migration/${logId}: Problem saving group endorsements ${Errors.toLogFormat(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3747,6 +3773,7 @@ async function updateGroupViaState({
|
|||
|
||||
// If we're not in the group, we won't receive endorsements
|
||||
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||
try {
|
||||
// Use the latest state of the group after applying changes
|
||||
const { groupId, membersV2 } = newAttributes;
|
||||
strictAssert(groupId, 'updateGroupViaState: Group must have groupId');
|
||||
|
@ -3762,6 +3789,11 @@ async function updateGroupViaState({
|
|||
});
|
||||
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
} catch (error) {
|
||||
log.warn(
|
||||
`updateGroupViaState/${logId}: Problem saving group endorsements ${Errors.toLogFormat(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -3951,6 +3983,7 @@ async function updateGroupViaLogs({
|
|||
|
||||
// If we're not in the group, we won't receive endorsements
|
||||
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||
try {
|
||||
log.info(`updateGroupViaLogs/${logId}: Saving group endorsements`);
|
||||
// Use the latest state of the group after applying changes
|
||||
const { membersV2 } = updates.newAttributes;
|
||||
|
@ -3967,6 +4000,11 @@ async function updateGroupViaLogs({
|
|||
});
|
||||
|
||||
await DataWriter.replaceAllEndorsementsForGroup(groupEndorsementData);
|
||||
} catch (error) {
|
||||
log.warn(
|
||||
`updateGroupViaLogs/${logId}: Problem saving group endorsements ${Errors.toLogFormat(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return updates;
|
||||
|
|
Loading…
Reference in a new issue