MemberPendingProfileKey can't have profile key

This commit is contained in:
Fedor Indutny 2023-06-05 09:22:27 -07:00 committed by GitHub
parent 702153a28d
commit e3d27bd00e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4953,13 +4953,6 @@ async function applyGroupChange({
timestamp: added.timestamp,
role: added.member.role || MEMBER_ROLE_ENUM.DEFAULT,
};
if (added.member && added.member.profileKey) {
newProfileKeys.push({
profileKey: added.member.profileKey,
uuid: addedUuid,
});
}
});
// deletePendingMembers?: Array<
@ -5597,21 +5590,7 @@ async function applyGroupState({
}
const previousMember = pendingMembers[member.member.userId];
if (
member.member.profileKey &&
(!previousMember ||
profileKeyHasChanged(
member.member.userId,
member.member.profileKey
))
) {
newProfileKeys.push({
profileKey: member.member.profileKey,
uuid: UUID.cast(member.member.userId),
});
} else if (!previousMember) {
otherChanges = true;
}
otherChanges = true;
if (
previousMember &&
@ -6824,7 +6803,6 @@ type DecryptedMemberPendingProfileKey = {
timestamp: number;
member: {
userId: string;
profileKey?: Uint8Array;
role?: Proto.Member.Role;
};
};
@ -6873,6 +6851,10 @@ function decryptMemberPendingProfileKey(
}
const { userId, profileKey } = member.member;
strictAssert(
Bytes.isEmpty(profileKey),
'decryptMemberPendingProfileKey: member has profileKey'
);
// userId
strictAssert(
@ -6902,30 +6884,6 @@ function decryptMemberPendingProfileKey(
return undefined;
}
// profileKey
let decryptedProfileKey: Uint8Array | undefined;
if (Bytes.isNotEmpty(profileKey)) {
try {
decryptedProfileKey = decryptProfileKey(
clientZkGroupCipher,
profileKey,
UUID.cast(decryptedUserId)
);
} catch (error) {
log.warn(
`decryptMemberPendingProfileKey/${logId}: Unable to decrypt pending member profileKey. Dropping profileKey.`,
Errors.toLogFormat(error)
);
}
if (!isValidProfileKey(decryptedProfileKey)) {
log.warn(
`decryptMemberPendingProfileKey/${logId}: Dropping profileKey, since it was invalid`
);
decryptedProfileKey = undefined;
}
}
// role
const role = dropNull(member.member.role);
@ -6939,7 +6897,6 @@ function decryptMemberPendingProfileKey(
timestamp,
member: {
userId: decryptedUserId,
profileKey: decryptedProfileKey,
role,
},
};