Cancel receipt send when encountering safety number change
This commit is contained in:
@@ -455,6 +455,13 @@ export class ConversationJobQueue extends JobQueue<ConversationQueueJobData> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === jobSet.Receipts) {
|
||||||
|
log.warn(
|
||||||
|
`Cancelling receipt send, since there were ${untrustedUuids.length} untrusted send targets.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.error(
|
log.error(
|
||||||
`Send failed because ${untrustedUuids.length} conversation(s) were untrusted. Adding to verification list.`
|
`Send failed because ${untrustedUuids.length} conversation(s) were untrusted. Adding to verification list.`
|
||||||
);
|
);
|
||||||
|
@@ -23,7 +23,6 @@ import type {
|
|||||||
ProfileKeyJobData,
|
ProfileKeyJobData,
|
||||||
} from '../conversationJobQueue';
|
} from '../conversationJobQueue';
|
||||||
import type { CallbackResultType } from '../../textsecure/Types.d';
|
import type { CallbackResultType } from '../../textsecure/Types.d';
|
||||||
import { isConversationAccepted } from '../../util/isConversationAccepted';
|
|
||||||
import { isConversationUnregistered } from '../../util/isConversationUnregistered';
|
import { isConversationUnregistered } from '../../util/isConversationUnregistered';
|
||||||
import type { ConversationAttributesType } from '../../model-types.d';
|
import type { ConversationAttributesType } from '../../model-types.d';
|
||||||
import {
|
import {
|
||||||
@@ -32,8 +31,7 @@ import {
|
|||||||
SendMessageProtoError,
|
SendMessageProtoError,
|
||||||
UnregisteredUserError,
|
UnregisteredUserError,
|
||||||
} from '../../textsecure/Errors';
|
} from '../../textsecure/Errors';
|
||||||
import { getRecipients } from '../../util/getRecipients';
|
import { shouldSendToConversation } from './shouldSendToConversation';
|
||||||
import { getUntrustedConversationUuids } from './getUntrustedConversationUuids';
|
|
||||||
|
|
||||||
export function canAllErrorsBeIgnored(
|
export function canAllErrorsBeIgnored(
|
||||||
conversation: ConversationAttributesType,
|
conversation: ConversationAttributesType,
|
||||||
@@ -104,24 +102,7 @@ export async function sendProfileKey(
|
|||||||
|
|
||||||
// Note: flags and the profileKey itself are all that matter in the proto.
|
// Note: flags and the profileKey itself are all that matter in the proto.
|
||||||
|
|
||||||
const recipients = getRecipients(conversation.attributes);
|
if (!shouldSendToConversation(conversation, log)) {
|
||||||
const untrustedUuids = getUntrustedConversationUuids(recipients);
|
|
||||||
if (untrustedUuids.length) {
|
|
||||||
log.info(
|
|
||||||
`conversation ${conversation.idForLogging()} has untrusted recipients; refusing to send`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isConversationAccepted(conversation.attributes)) {
|
|
||||||
log.info(
|
|
||||||
`conversation ${conversation.idForLogging()} is not accepted; refusing to send`
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (conversation.isBlocked()) {
|
|
||||||
log.info(
|
|
||||||
`conversation ${conversation.idForLogging()} is blocked; refusing to send`
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,12 +7,16 @@ import type {
|
|||||||
ConversationQueueJobBundle,
|
ConversationQueueJobBundle,
|
||||||
ReceiptsJobData,
|
ReceiptsJobData,
|
||||||
} from '../conversationJobQueue';
|
} from '../conversationJobQueue';
|
||||||
|
import { shouldSendToConversation } from './shouldSendToConversation';
|
||||||
|
|
||||||
export async function sendReceipts(
|
export async function sendReceipts(
|
||||||
_conversation: ConversationModel,
|
conversation: ConversationModel,
|
||||||
{ log }: ConversationQueueJobBundle,
|
{ log }: ConversationQueueJobBundle,
|
||||||
data: ReceiptsJobData
|
data: ReceiptsJobData
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
if (!shouldSendToConversation(conversation, log)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await sendReceiptsTask({
|
await sendReceiptsTask({
|
||||||
log,
|
log,
|
||||||
receipts: data.receipts,
|
receipts: data.receipts,
|
||||||
|
39
ts/jobs/helpers/shouldSendToConversation.ts
Normal file
39
ts/jobs/helpers/shouldSendToConversation.ts
Normal file
@@ -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;
|
||||||
|
}
|
Reference in New Issue
Block a user