2023-02-06 17:24:34 +00:00
|
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import type { ConversationModel } from '../../models/conversations';
|
|
|
|
import { sendReceipts as sendReceiptsTask } from '../../util/sendReceipts';
|
|
|
|
import type {
|
|
|
|
ConversationQueueJobBundle,
|
|
|
|
ReceiptsJobData,
|
|
|
|
} from '../conversationJobQueue';
|
2023-02-13 18:02:40 +00:00
|
|
|
import { shouldSendToConversation } from './shouldSendToConversation';
|
2023-02-06 17:24:34 +00:00
|
|
|
|
|
|
|
export async function sendReceipts(
|
2023-02-13 18:02:40 +00:00
|
|
|
conversation: ConversationModel,
|
2023-02-06 17:24:34 +00:00
|
|
|
{ log }: ConversationQueueJobBundle,
|
|
|
|
data: ReceiptsJobData
|
|
|
|
): Promise<void> {
|
2023-02-13 18:02:40 +00:00
|
|
|
if (!shouldSendToConversation(conversation, log)) {
|
|
|
|
return;
|
|
|
|
}
|
2023-02-06 17:24:34 +00:00
|
|
|
await sendReceiptsTask({
|
|
|
|
log,
|
|
|
|
receipts: data.receipts,
|
|
|
|
type: data.receiptsType,
|
|
|
|
});
|
|
|
|
}
|