Fetch full group state if last epoch is stale
This commit is contained in:
parent
e8651afa0b
commit
0f5a01f2b2
2 changed files with 25 additions and 1 deletions
25
ts/groups.ts
25
ts/groups.ts
|
@ -3622,6 +3622,7 @@ async function getGroupDelta({
|
||||||
changes,
|
changes,
|
||||||
group,
|
group,
|
||||||
newRevision: latestRevision,
|
newRevision: latestRevision,
|
||||||
|
serverPublicParamsBase64,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3629,15 +3630,17 @@ async function integrateGroupChanges({
|
||||||
group,
|
group,
|
||||||
newRevision,
|
newRevision,
|
||||||
changes,
|
changes,
|
||||||
|
serverPublicParamsBase64,
|
||||||
}: {
|
}: {
|
||||||
group: ConversationAttributesType;
|
group: ConversationAttributesType;
|
||||||
newRevision: number | undefined;
|
newRevision: number | undefined;
|
||||||
changes: Array<Proto.IGroupChanges>;
|
changes: Array<Proto.IGroupChanges>;
|
||||||
|
serverPublicParamsBase64: string;
|
||||||
}): Promise<UpdatesResultType> {
|
}): Promise<UpdatesResultType> {
|
||||||
const logId = idForLogging(group.groupId);
|
const logId = idForLogging(group.groupId);
|
||||||
let attributes = group;
|
let attributes = group;
|
||||||
const finalMessages: Array<Array<GroupChangeMessageType>> = [];
|
const finalMessages: Array<Array<GroupChangeMessageType>> = [];
|
||||||
const finalMembers: Array<Array<MemberType>> = [];
|
let finalMembers: Array<Array<MemberType>> = [];
|
||||||
|
|
||||||
const imax = changes.length;
|
const imax = changes.length;
|
||||||
for (let i = 0; i < imax; i += 1) {
|
for (let i = 0; i < imax; i += 1) {
|
||||||
|
@ -3721,6 +3724,24 @@ async function integrateGroupChanges({
|
||||||
Errors.toLogFormat(error)
|
Errors.toLogFormat(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else if (attributes.lastFetchedEpoch !== SUPPORTED_CHANGE_EPOCH) {
|
||||||
|
log.info(
|
||||||
|
`integrateGroupChanges(${logId}): last fetched epoch ` +
|
||||||
|
`${group.lastFetchedEpoch ?? '?'} is stale. ` +
|
||||||
|
'Refreshing group state'
|
||||||
|
);
|
||||||
|
const {
|
||||||
|
newAttributes: updatedAttributes,
|
||||||
|
groupChangeMessages: extraChanges,
|
||||||
|
members: updatedMembers,
|
||||||
|
} = await updateGroupViaState({
|
||||||
|
group: attributes,
|
||||||
|
serverPublicParamsBase64,
|
||||||
|
});
|
||||||
|
|
||||||
|
attributes = updatedAttributes;
|
||||||
|
finalMessages.push(extraChanges);
|
||||||
|
finalMembers = [updatedMembers];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is our first fetch, we will collapse this down to one set of messages
|
// If this is our first fetch, we will collapse this down to one set of messages
|
||||||
|
@ -3839,6 +3860,7 @@ async function integrateGroupChange({
|
||||||
!groupChange ||
|
!groupChange ||
|
||||||
!isChangeSupported ||
|
!isChangeSupported ||
|
||||||
isFirstFetch ||
|
isFirstFetch ||
|
||||||
|
(groupState && group.lastFetchedEpoch !== SUPPORTED_CHANGE_EPOCH) ||
|
||||||
(isMoreThanOneVersionUp && !weAreAwaitingApproval)
|
(isMoreThanOneVersionUp && !weAreAwaitingApproval)
|
||||||
) {
|
) {
|
||||||
if (!groupState) {
|
if (!groupState) {
|
||||||
|
@ -4993,6 +5015,7 @@ async function applyGroupState({
|
||||||
|
|
||||||
// version
|
// version
|
||||||
result.revision = version;
|
result.revision = version;
|
||||||
|
result.lastFetchedEpoch = SUPPORTED_CHANGE_EPOCH;
|
||||||
|
|
||||||
// title
|
// title
|
||||||
// Note: During decryption, title becomes a GroupAttributeBlob
|
// Note: During decryption, title becomes a GroupAttributeBlob
|
||||||
|
|
1
ts/model-types.d.ts
vendored
1
ts/model-types.d.ts
vendored
|
@ -331,6 +331,7 @@ export type ConversationAttributesType = {
|
||||||
secretParams?: string;
|
secretParams?: string;
|
||||||
publicParams?: string;
|
publicParams?: string;
|
||||||
revision?: number;
|
revision?: number;
|
||||||
|
lastFetchedEpoch?: number;
|
||||||
senderKeyInfo?: SenderKeyInfoType;
|
senderKeyInfo?: SenderKeyInfoType;
|
||||||
|
|
||||||
// GroupV2 other fields
|
// GroupV2 other fields
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue