Don't expect endorsement response on group leave
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
bb93a5516f
commit
09b43bb0ac
2 changed files with 23 additions and 39 deletions
35
ts/groups.ts
35
ts/groups.ts
|
@ -96,10 +96,7 @@ import { SeenStatus } from './MessageSeenStatus';
|
||||||
import { incrementMessageCounter } from './util/incrementMessageCounter';
|
import { incrementMessageCounter } from './util/incrementMessageCounter';
|
||||||
import { sleep } from './util/sleep';
|
import { sleep } from './util/sleep';
|
||||||
import { groupInvitesRoute } from './util/signalRoutes';
|
import { groupInvitesRoute } from './util/signalRoutes';
|
||||||
import {
|
import { decodeGroupSendEndorsementResponse } from './util/groupSendEndorsements';
|
||||||
decodeGroupSendEndorsementResponse,
|
|
||||||
isGroupSendEndorsementResponseEmpty,
|
|
||||||
} from './util/groupSendEndorsements';
|
|
||||||
|
|
||||||
type AccessRequiredEnum = Proto.AccessControl.AccessRequired;
|
type AccessRequiredEnum = Proto.AccessControl.AccessRequired;
|
||||||
|
|
||||||
|
@ -1568,10 +1565,6 @@ export async function modifyGroupV2({
|
||||||
const { groupChange, groupSendEndorsementResponse } =
|
const { groupChange, groupSendEndorsementResponse } =
|
||||||
groupChangeResponse;
|
groupChangeResponse;
|
||||||
strictAssert(groupChange, 'modifyGroupV2: missing groupChange');
|
strictAssert(groupChange, 'modifyGroupV2: missing groupChange');
|
||||||
strictAssert(
|
|
||||||
groupSendEndorsementResponse,
|
|
||||||
'modifyGroupV2: missing groupSendEndorsementResponse'
|
|
||||||
);
|
|
||||||
|
|
||||||
const groupChangeBuffer =
|
const groupChangeBuffer =
|
||||||
Proto.GroupChange.encode(groupChange).finish();
|
Proto.GroupChange.encode(groupChange).finish();
|
||||||
|
@ -1606,6 +1599,10 @@ export async function modifyGroupV2({
|
||||||
const { membersV2 } = conversation.attributes;
|
const { membersV2 } = conversation.attributes;
|
||||||
strictAssert(membersV2, 'modifyGroupV2: missing membersV2');
|
strictAssert(membersV2, 'modifyGroupV2: missing membersV2');
|
||||||
|
|
||||||
|
// If we are no longer a member - endorsement won't be present
|
||||||
|
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||||
|
log.info(`modifyGroupV2/${logId}: Saving group endorsements`);
|
||||||
|
|
||||||
const groupEndorsementData = decodeGroupSendEndorsementResponse({
|
const groupEndorsementData = decodeGroupSendEndorsementResponse({
|
||||||
groupId,
|
groupId,
|
||||||
groupSendEndorsementResponse,
|
groupSendEndorsementResponse,
|
||||||
|
@ -1616,6 +1613,7 @@ export async function modifyGroupV2({
|
||||||
await dataInterface.replaceAllEndorsementsForGroup(
|
await dataInterface.replaceAllEndorsementsForGroup(
|
||||||
groupEndorsementData
|
groupEndorsementData
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we've gotten here with no error, we exit!
|
// If we've gotten here with no error, we exit!
|
||||||
|
@ -1920,7 +1918,7 @@ export async function createGroupV2(
|
||||||
|
|
||||||
const { groupSendEndorsementResponse } = groupResponse;
|
const { groupSendEndorsementResponse } = groupResponse;
|
||||||
strictAssert(
|
strictAssert(
|
||||||
groupSendEndorsementResponse,
|
Bytes.isNotEmpty(groupSendEndorsementResponse),
|
||||||
'missing groupSendEndorsementResponse'
|
'missing groupSendEndorsementResponse'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2491,7 +2489,7 @@ export async function initiateMigrationToGroupV2(
|
||||||
updateConversation(conversation.attributes);
|
updateConversation(conversation.attributes);
|
||||||
|
|
||||||
strictAssert(
|
strictAssert(
|
||||||
groupSendEndorsementResponse,
|
Bytes.isNotEmpty(groupSendEndorsementResponse),
|
||||||
'missing groupSendEndorsementResponse'
|
'missing groupSendEndorsementResponse'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2978,7 +2976,7 @@ export async function respondToGroupV2Migration({
|
||||||
sentAt,
|
sentAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isGroupSendEndorsementResponseEmpty(groupSendEndorsementResponse)) {
|
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||||
const { membersV2 } = conversation.attributes;
|
const { membersV2 } = conversation.attributes;
|
||||||
strictAssert(membersV2, 'missing membersV2');
|
strictAssert(membersV2, 'missing membersV2');
|
||||||
|
|
||||||
|
@ -3748,10 +3746,6 @@ async function updateGroupViaState({
|
||||||
|
|
||||||
const { group: groupState, groupSendEndorsementResponse } = groupResponse;
|
const { group: groupState, groupSendEndorsementResponse } = groupResponse;
|
||||||
strictAssert(groupState, 'updateGroupViaState: Group state must be present');
|
strictAssert(groupState, 'updateGroupViaState: Group state must be present');
|
||||||
strictAssert(
|
|
||||||
groupSendEndorsementResponse,
|
|
||||||
'updateGroupViaState: Endorsement must be present'
|
|
||||||
);
|
|
||||||
|
|
||||||
const decryptedGroupState = decryptGroupState(
|
const decryptedGroupState = decryptGroupState(
|
||||||
groupState,
|
groupState,
|
||||||
|
@ -3770,15 +3764,14 @@ async function updateGroupViaState({
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we're not in the group, we won't receive endorsements
|
// If we're not in the group, we won't receive endorsements
|
||||||
if (
|
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||||
groupSendEndorsementResponse != null &&
|
|
||||||
groupSendEndorsementResponse.byteLength > 0
|
|
||||||
) {
|
|
||||||
// Use the latest state of the group after applying changes
|
// Use the latest state of the group after applying changes
|
||||||
const { groupId, membersV2 } = newAttributes;
|
const { groupId, membersV2 } = newAttributes;
|
||||||
strictAssert(groupId, 'updateGroupViaState: Group must have groupId');
|
strictAssert(groupId, 'updateGroupViaState: Group must have groupId');
|
||||||
strictAssert(membersV2, 'updateGroupViaState: Group must have membersV2');
|
strictAssert(membersV2, 'updateGroupViaState: Group must have membersV2');
|
||||||
|
|
||||||
|
log.info(`getCurrentGroupState/${logId}: Saving group endorsements`);
|
||||||
|
|
||||||
const groupEndorsementData = decodeGroupSendEndorsementResponse({
|
const groupEndorsementData = decodeGroupSendEndorsementResponse({
|
||||||
groupId,
|
groupId,
|
||||||
groupSendEndorsementResponse,
|
groupSendEndorsementResponse,
|
||||||
|
@ -3975,8 +3968,8 @@ async function updateGroupViaLogs({
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we're not in the group, we won't receive endorsements
|
// If we're not in the group, we won't receive endorsements
|
||||||
if (!isGroupSendEndorsementResponseEmpty(groupSendEndorsementResponse)) {
|
if (Bytes.isNotEmpty(groupSendEndorsementResponse)) {
|
||||||
log.info('updateGroupViaLogs: Saving group endorsements');
|
log.info(`updateGroupViaLogs/${logId}: Saving group endorsements`);
|
||||||
// Use the latest state of the group after applying changes
|
// Use the latest state of the group after applying changes
|
||||||
const { membersV2 } = updates.newAttributes;
|
const { membersV2 } = updates.newAttributes;
|
||||||
strictAssert(
|
strictAssert(
|
||||||
|
|
|
@ -15,15 +15,6 @@ import { fromAciObject } from '../types/ServiceId';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import type { GroupV2MemberType } from '../model-types';
|
import type { GroupV2MemberType } from '../model-types';
|
||||||
|
|
||||||
/**
|
|
||||||
* Despite being optional, the protobufs decoding will create an empty uint8array
|
|
||||||
*/
|
|
||||||
export function isGroupSendEndorsementResponseEmpty(
|
|
||||||
value: Uint8Array | null | undefined
|
|
||||||
): value is null | undefined {
|
|
||||||
return value == null || value.byteLength === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function decodeGroupSendEndorsementResponse({
|
export function decodeGroupSendEndorsementResponse({
|
||||||
groupId,
|
groupId,
|
||||||
groupSendEndorsementResponse,
|
groupSendEndorsementResponse,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue