From d8e6516fb91d99d800d8d363f5eb6b6e1c4265a0 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:12:35 -0400 Subject: [PATCH] Fixes isAccepted logic when calling it for the first time --- ts/models/messages.ts | 12 ++++++------ ts/util/isConversationAccepted.ts | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ts/models/messages.ts b/ts/models/messages.ts index f77d87674..63a67a29e 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -1927,11 +1927,13 @@ export class MessageModel extends window.Backbone.Model { ); if ( - type === 'story' && - !isConversationAccepted(conversation.attributes) + isStory(message.attributes) && + !isConversationAccepted(conversation.attributes, { + ignoreEmptyConvo: true, + }) ) { log.info( - 'handleDataMessage: dropping story from !whitelisted', + 'handleDataMessage: dropping story from !accepted', this.getSenderIdentifier() ); confirm(); @@ -2572,9 +2574,7 @@ export class MessageModel extends window.Backbone.Model { if ( this.hasAttachmentDownloads() && - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - (this.getConversation()!.getAccepted() || - isOutgoing(message.attributes)) && + (conversation.getAccepted() || isOutgoing(message.attributes)) && !shouldHoldOffDownload ) { if (window.attachmentDownloadQueue) { diff --git a/ts/util/isConversationAccepted.ts b/ts/util/isConversationAccepted.ts index c52c3d3a4..daaa4132d 100644 --- a/ts/util/isConversationAccepted.ts +++ b/ts/util/isConversationAccepted.ts @@ -11,7 +11,8 @@ import { isInSystemContacts } from './isInSystemContacts'; * of message requests */ export function isConversationAccepted( - conversationAttrs: ConversationAttributesType + conversationAttrs: ConversationAttributesType, + { ignoreEmptyConvo = false } = {} ): boolean { const messageRequestsEnabled = window.Signal.RemoteConfig.isEnabled( 'desktop.messageRequests' @@ -40,7 +41,9 @@ export function isConversationAccepted( const hasNoMessages = (conversationAttrs.messageCount || 0) === 0; const isEmptyPrivateConvo = - hasNoMessages && isDirectConversation(conversationAttrs); + hasNoMessages && + isDirectConversation(conversationAttrs) && + !ignoreEmptyConvo; const isEmptyWhitelistedGroup = hasNoMessages && !isDirectConversation(conversationAttrs) &&