Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cancel receipt send when encountering safety number change
Co-authored-by: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com>
- Loading branch information
1 parent
32afdb3
commit 6a2b3c3
Showing
4 changed files
with
53 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2023 Signal Messenger, LLC | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import type { ConversationModel } from '../../models/conversations'; | ||
import type { LoggerType } from '../../types/Logging'; | ||
import { getRecipients } from '../../util/getRecipients'; | ||
import { isConversationAccepted } from '../../util/isConversationAccepted'; | ||
import { getUntrustedConversationUuids } from './getUntrustedConversationUuids'; | ||
|
||
export function shouldSendToConversation( | ||
conversation: ConversationModel, | ||
log: LoggerType | ||
): boolean { | ||
const recipients = getRecipients(conversation.attributes); | ||
const untrustedUuids = getUntrustedConversationUuids(recipients); | ||
|
||
if (untrustedUuids.length) { | ||
log.info( | ||
`conversation ${conversation.idForLogging()} has untrusted recipients; refusing to send` | ||
); | ||
return false; | ||
} | ||
|
||
if (!isConversationAccepted(conversation.attributes)) { | ||
log.info( | ||
`conversation ${conversation.idForLogging()} is not accepted; refusing to send` | ||
); | ||
return false; | ||
} | ||
|
||
if (conversation.isBlocked()) { | ||
log.info( | ||
`conversation ${conversation.idForLogging()} is blocked; refusing to send` | ||
); | ||
return false; | ||
} | ||
|
||
return true; | ||
} |