Fix profile key oscillations in groups
This commit is contained in:
parent
1d07203fa9
commit
ecab90041b
1 changed files with 39 additions and 14 deletions
45
ts/groups.ts
45
ts/groups.ts
|
@ -4925,10 +4925,17 @@ async function applyGroupChange({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aci === sourceServiceId || !hasProfileKey(aci)) {
|
||||||
newProfileKeys.push({
|
newProfileKeys.push({
|
||||||
profileKey,
|
profileKey,
|
||||||
aci,
|
aci,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
log.warn(
|
||||||
|
`applyGroupChange/${logId}: Attempt to modify member profile key ` +
|
||||||
|
'failed; sourceServiceId is not the same as change aci'
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// addPendingMembers?: Array<
|
// addPendingMembers?: Array<
|
||||||
|
@ -5433,6 +5440,16 @@ function profileKeyHasChanged(
|
||||||
return newBase64 !== existingBase64;
|
return newBase64 !== existingBase64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasProfileKey(userId: ServiceIdString) {
|
||||||
|
const conversation = window.ConversationController.get(userId);
|
||||||
|
if (!conversation) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingBase64 = conversation.get('profileKey');
|
||||||
|
return existingBase64 !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
async function applyGroupState({
|
async function applyGroupState({
|
||||||
group,
|
group,
|
||||||
groupState,
|
groupState,
|
||||||
|
@ -5540,15 +5557,19 @@ async function applyGroupState({
|
||||||
}
|
}
|
||||||
|
|
||||||
const previousMember = members[member.userId];
|
const previousMember = members[member.userId];
|
||||||
if (
|
if (member.profileKey && !hasProfileKey(member.userId)) {
|
||||||
member.profileKey &&
|
|
||||||
(!previousMember ||
|
|
||||||
profileKeyHasChanged(member.userId, member.profileKey))
|
|
||||||
) {
|
|
||||||
newProfileKeys.push({
|
newProfileKeys.push({
|
||||||
profileKey: member.profileKey,
|
profileKey: member.profileKey,
|
||||||
aci: member.userId,
|
aci: member.userId,
|
||||||
});
|
});
|
||||||
|
} else if (
|
||||||
|
member.profileKey &&
|
||||||
|
profileKeyHasChanged(member.userId, member.profileKey)
|
||||||
|
) {
|
||||||
|
log.warn(
|
||||||
|
`applyGroupState(${logId}): Member ${member.userId} had different profileKey`
|
||||||
|
);
|
||||||
|
otherChanges = true;
|
||||||
} else if (!previousMember) {
|
} else if (!previousMember) {
|
||||||
otherChanges = true;
|
otherChanges = true;
|
||||||
}
|
}
|
||||||
|
@ -5634,15 +5655,19 @@ async function applyGroupState({
|
||||||
result.pendingAdminApprovalV2 = groupState.membersPendingAdminApproval.map(
|
result.pendingAdminApprovalV2 = groupState.membersPendingAdminApproval.map(
|
||||||
member => {
|
member => {
|
||||||
const previousMember = pendingAdminApprovalMembers[member.userId];
|
const previousMember = pendingAdminApprovalMembers[member.userId];
|
||||||
if (
|
if (member.profileKey && !hasProfileKey(member.userId)) {
|
||||||
member.profileKey &&
|
|
||||||
(!previousMember ||
|
|
||||||
profileKeyHasChanged(member.userId, member.profileKey))
|
|
||||||
) {
|
|
||||||
newProfileKeys.push({
|
newProfileKeys.push({
|
||||||
profileKey: member.profileKey,
|
profileKey: member.profileKey,
|
||||||
aci: member.userId,
|
aci: member.userId,
|
||||||
});
|
});
|
||||||
|
} else if (
|
||||||
|
member.profileKey &&
|
||||||
|
profileKeyHasChanged(member.userId, member.profileKey)
|
||||||
|
) {
|
||||||
|
log.warn(
|
||||||
|
`applyGroupState(${logId}): Member ${member.userId} had different profileKey`
|
||||||
|
);
|
||||||
|
otherChanges = true;
|
||||||
} else if (!previousMember) {
|
} else if (!previousMember) {
|
||||||
otherChanges = true;
|
otherChanges = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue