mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-17 13:00:48 +00:00
fix(cron): merge failureAlert mode/accountId and preserve failureDestination on updates
- Fix mergeCronFailureAlert to merge mode and accountId fields - Fix mergeCronDelivery to preserve failureDestination on updates - Fix isSameDeliveryTarget to use 'announce' as default instead of 'none' to properly detect duplicates when delivery.mode is undefined
This commit is contained in:
committed by
Tak Hoffman
parent
5403d1bdc2
commit
099f3c7341
@@ -174,7 +174,7 @@ function isSameDeliveryTarget(
|
||||
delivery: CronDelivery,
|
||||
failurePlan: CronFailureDeliveryPlan,
|
||||
): boolean {
|
||||
const primaryMode = delivery.mode ?? "none";
|
||||
const primaryMode = delivery.mode ?? "announce";
|
||||
if (primaryMode === "none") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -668,6 +668,7 @@ function mergeCronDelivery(
|
||||
to: existing?.to,
|
||||
accountId: existing?.accountId,
|
||||
bestEffort: existing?.bestEffort,
|
||||
failureDestination: existing?.failureDestination,
|
||||
};
|
||||
|
||||
if (typeof patch.mode === "string") {
|
||||
@@ -685,6 +686,20 @@ function mergeCronDelivery(
|
||||
if (typeof patch.bestEffort === "boolean") {
|
||||
next.bestEffort = patch.bestEffort;
|
||||
}
|
||||
if ("failureDestination" in patch) {
|
||||
if (patch.failureDestination === undefined) {
|
||||
next.failureDestination = undefined;
|
||||
} else {
|
||||
const existingFd = next.failureDestination;
|
||||
const patchFd = patch.failureDestination;
|
||||
next.failureDestination = {
|
||||
channel: patchFd?.channel ?? existingFd?.channel,
|
||||
to: patchFd?.to ?? existingFd?.to,
|
||||
accountId: patchFd?.accountId ?? existingFd?.accountId,
|
||||
mode: patchFd?.mode ?? existingFd?.mode,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
@@ -719,6 +734,14 @@ function mergeCronFailureAlert(
|
||||
: -1;
|
||||
next.cooldownMs = cooldownMs >= 0 ? Math.floor(cooldownMs) : undefined;
|
||||
}
|
||||
if ("mode" in patch) {
|
||||
const mode = typeof patch.mode === "string" ? patch.mode.trim() : "";
|
||||
next.mode = mode === "announce" || mode === "webhook" ? mode : undefined;
|
||||
}
|
||||
if ("accountId" in patch) {
|
||||
const accountId = typeof patch.accountId === "string" ? patch.accountId.trim() : "";
|
||||
next.accountId = accountId ? accountId : undefined;
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user