Files
Desktop/ts/util/enqueuePollCreateForSend.dom.ts
2026-02-25 18:53:37 -06:00

35 lines
804 B
TypeScript

// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ConversationModel } from '../models/conversations.preload.js';
import { isDirectConversation } from './whatTypeOfConversation.dom.js';
import {
isPollSend1to1Enabled,
type PollCreateType,
} from '../types/Polls.dom.js';
export async function enqueuePollCreateForSend(
conversation: ConversationModel,
poll: PollCreateType
): Promise<void> {
if (
isDirectConversation(conversation.attributes) &&
!isPollSend1to1Enabled()
) {
throw new Error(
'enqueuePollCreateForSend: 1:1 poll sending is not enabled'
);
}
await conversation.enqueueMessageForSend(
{
attachments: [],
body: undefined,
poll,
},
{
timestamp: Date.now(),
}
);
}