Handle Safety Number changes while sending a story

This commit is contained in:
Josh Perez 2022-08-19 14:05:31 -04:00 committed by GitHub
parent d036803df9
commit 0fb45f045d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 392 additions and 44 deletions

View file

@ -2822,19 +2822,22 @@ export class ConversationModel extends window.Backbone
return window.textsecure.storage.protocol.setApproval(uuid, true);
}
safeIsUntrusted(): boolean {
safeIsUntrusted(timestampThreshold?: number): boolean {
try {
const uuid = this.getUuid();
strictAssert(uuid, `No uuid for conversation: ${this.id}`);
return window.textsecure.storage.protocol.isUntrusted(uuid);
return window.textsecure.storage.protocol.isUntrusted(
uuid,
timestampThreshold
);
} catch (err) {
return false;
}
}
isUntrusted(): boolean {
isUntrusted(timestampThreshold?: number): boolean {
if (isDirectConversation(this.attributes)) {
return this.safeIsUntrusted();
return this.safeIsUntrusted(timestampThreshold);
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (!this.contactCollection!.length) {
@ -2846,13 +2849,13 @@ export class ConversationModel extends window.Backbone
if (isMe(contact.attributes)) {
return false;
}
return contact.safeIsUntrusted();
return contact.safeIsUntrusted(timestampThreshold);
});
}
getUntrusted(): Array<ConversationModel> {
getUntrusted(timestampThreshold?: number): Array<ConversationModel> {
if (isDirectConversation(this.attributes)) {
if (this.isUntrusted()) {
if (this.isUntrusted(timestampThreshold)) {
return [this];
}
return [];
@ -2863,7 +2866,7 @@ export class ConversationModel extends window.Backbone
if (isMe(contact.attributes)) {
return false;
}
return contact.isUntrusted();
return contact.isUntrusted(timestampThreshold);
}) || []
);
}