refactor(outbound): dedupe poll threading + tighten duration semantics

This commit is contained in:
Peter Steinberger
2026-02-14 18:53:23 +01:00
parent f47584fec8
commit 4b9cb46c6e
7 changed files with 85 additions and 33 deletions

View File

@@ -21,6 +21,7 @@ import {
resolveChannelId,
sendDiscordMedia,
sendDiscordText,
SUPPRESS_NOTIFICATIONS_FLAG,
} from "./send.shared.js";
import {
ensureOggOpus,
@@ -273,9 +274,11 @@ export async function sendPollDiscord(
const recipient = await parseAndResolveRecipient(to, opts.accountId);
const { channelId } = await resolveChannelId(rest, recipient, request);
const content = opts.content?.trim();
if (poll.durationSeconds !== undefined) {
throw new Error("Discord polls do not support durationSeconds; use durationHours");
}
const payload = normalizeDiscordPollInput(poll);
// Discord message flag for silent/suppress notifications (matches send.shared.ts)
const flags = opts.silent ? 1 << 12 : undefined;
const flags = opts.silent ? SUPPRESS_NOTIFICATIONS_FLAG : undefined;
const res = (await request(
() =>
rest.post(Routes.channelMessages(channelId), {