From 0d20e521287582773f54cef0d067482e5430a37d Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:33:45 -0500 Subject: [PATCH] Skip unsealed typing messages with active challenges Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com> --- ts/challenge.ts | 4 ++++ ts/models/conversations.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/ts/challenge.ts b/ts/challenge.ts index f7f32cd3a..1fcfd8840 100644 --- a/ts/challenge.ts +++ b/ts/challenge.ts @@ -334,6 +334,10 @@ export class ChallengeHandler { ); } + public areAnyRegistered(): boolean { + return this.registeredConversations.size > 0; + } + public isRegistered(conversationId: string): boolean { return this.registeredConversations.has(conversationId); } diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 4efb4be45..02987dd71 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -1298,6 +1298,10 @@ export class ConversationModel extends window.Backbone return; } + if (isGroupV1(this.attributes)) { + return; + } + // Coalesce multiple sendTypingMessage calls into one. // // `lastIsTyping` is set to the last `isTyping` value passed to the @@ -1306,6 +1310,18 @@ export class ConversationModel extends window.Backbone // in effect be ignored. this.lastIsTyping = isTyping; + // If captchas are active, then we should drop typing messages because + // they're less important and could overwhelm the queue. + if ( + window.Signal.challengeHandler?.areAnyRegistered() && + this.isSealedSenderDisabled() + ) { + log.info( + `sendTypingMessage(${this.idForLogging()}): Challenge is registered and can't send sealed, ignoring` + ); + return; + } + await this.queueJob('sendTypingMessage', async () => { const groupMembers = this.getRecipients(); @@ -4601,6 +4617,19 @@ export class ConversationModel extends window.Backbone return message; } + isSealedSenderDisabled(): boolean { + const members = this.getMembers(); + if ( + members.some( + member => member.get('sealedSender') === SEALED_SENDER.DISABLED + ) + ) { + return true; + } + + return false; + } + isSearchable(): boolean { return !this.get('left'); }