fix(cron): allow clearing accountId and treat undefined global mode as announce

- UI: always include accountId in patch so users can clear it
- delivery.ts: treat undefined global mode as announce when comparing for clearing inherited 'to'
This commit is contained in:
Evgeny Zislis
2026-03-02 05:19:47 +02:00
committed by Tak Hoffman
parent 62f71fa401
commit bf86d07e70
2 changed files with 6 additions and 3 deletions

View File

@@ -171,7 +171,9 @@ export function resolveFailureDestination(
// Mode was explicitly overridden - clear inherited 'to' since URL semantics differ
// between announce (channel recipient) and webhook (HTTP endpoint)
// But preserve explicit 'to' that was set at job level
if (!jobToExplicit && globalConfig?.mode !== jobMode) {
// Treat undefined global mode as "announce" for comparison
const globalMode = globalConfig?.mode ?? "announce";
if (!jobToExplicit && globalMode !== jobMode) {
to = undefined;
}
mode = jobMode;

View File

@@ -606,12 +606,13 @@ function buildFailureAlert(form: CronFormState) {
channel: form.failureAlertChannel.trim() || CRON_CHANNEL_LAST,
to: form.failureAlertTo.trim() || undefined,
...(cooldownMs !== undefined ? { cooldownMs } : {}),
...(accountId ? { accountId } : {}),
};
// Always include mode so users can switch between webhook/announce
// Always include mode and accountId so users can switch/clear them
if (deliveryMode) {
patch.mode = deliveryMode;
}
// Include accountId if explicitly set, or send undefined to allow clearing
patch.accountId = accountId || undefined;
return patch;
}