Prevent send and show toast for invalid conversations

This commit is contained in:
Scott Nonnenberg 2020-11-16 13:34:41 -08:00 committed by GitHub
parent 34be0744d2
commit 3ee830ae63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 45 deletions

View file

@ -266,7 +266,8 @@ export class ConversationModel extends window.Backbone.Model<
return false;
}
return fromEncodedBinaryToArrayBuffer(groupId).byteLength === 16;
const buffer = fromEncodedBinaryToArrayBuffer(groupId);
return buffer.byteLength === window.Signal.Groups.ID_V1_LENGTH;
}
isGroupV2(): boolean {
@ -277,7 +278,10 @@ export class ConversationModel extends window.Backbone.Model<
const groupVersion = this.get('groupVersion') || 0;
return groupVersion === 2 && base64ToArrayBuffer(groupId).byteLength === 32;
return (
groupVersion === 2 &&
base64ToArrayBuffer(groupId).byteLength === window.Signal.Groups.ID_LENGTH
);
}
isMemberPending(conversationId: string): boolean {
@ -822,6 +826,10 @@ export class ConversationModel extends window.Backbone.Model<
});
}
isValid(): boolean {
return this.isPrivate() || this.isGroupV1() || this.isGroupV2();
}
maybeRepairGroupV2(data: {
masterKey: string;
secretParams: string;