import type { Payload } from "payload"; export const POLL_CHANGED_CHANNEL = "ptf_poll_changed"; /** * Tell the standalone Discord bot that a poll changed, so it re-renders * immediately instead of waiting for its next poll tick. Mirrors * `notifyAttendanceChanged`; the bot also reconciles on a timer, so a dropped * notification only costs latency. */ export async function notifyPollChanged(payload: Payload, pollId: number): Promise { try { await payload.db.pool.query("SELECT pg_notify($1, $2)", [ POLL_CHANGED_CHANNEL, JSON.stringify({ pollId }), ]); } catch { // The bot's timer is the fallback; a notify failure must never fail a vote. } }