diff --git a/ts/challenge.ts b/ts/challenge.ts index f7f32cd3ac40..1fcfd88408f5 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 4efb4be4506b..02987dd71cf0 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'); }