Skip unsealed typing messages with active challenges

This commit is contained in:
ayumi-signal 2024-07-19 15:06:44 -07:00 committed by GitHub
parent b8ef9e5cbc
commit c93a211595
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View file

@ -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);
}

View file

@ -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');
}