refactor(cron): improve delivery configuration handling in CronJobEditor and CLI
- Enhanced the delivery configuration logic in CronJobEditor to explicitly set the bestEffort property based on job settings. - Refactored the CLI command to streamline delivery object creation, ensuring proper handling of optional fields like channel and to. - Improved code readability and maintainability by restructuring delivery assignment logic. This update clarifies the delivery configuration process, enhancing the reliability of job settings in both the editor and CLI.
This commit is contained in:
committed by
Peter Steinberger
parent
64df61f697
commit
246896d64b
@@ -107,7 +107,11 @@ extension CronJobEditor {
|
||||
delivery["channel"] = trimmed.isEmpty ? "last" : trimmed
|
||||
let to = self.to.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if !to.isEmpty { delivery["to"] = to }
|
||||
if self.bestEffortDeliver { delivery["bestEffort"] = true }
|
||||
if self.bestEffortDeliver {
|
||||
delivery["bestEffort"] = true
|
||||
} else if self.job?.delivery?.bestEffort == true {
|
||||
delivery["bestEffort"] = false
|
||||
}
|
||||
}
|
||||
return delivery
|
||||
}
|
||||
|
||||
@@ -183,16 +183,19 @@ export function registerCronEditCommand(cron: Command) {
|
||||
: opts.deliver === false
|
||||
? "none"
|
||||
: "announce";
|
||||
patch.delivery = {
|
||||
mode: deliveryMode,
|
||||
channel:
|
||||
typeof opts.channel === "string" && opts.channel.trim()
|
||||
? opts.channel.trim()
|
||||
: undefined,
|
||||
to: typeof opts.to === "string" && opts.to.trim() ? opts.to.trim() : undefined,
|
||||
bestEffort:
|
||||
typeof opts.bestEffortDeliver === "boolean" ? opts.bestEffortDeliver : undefined,
|
||||
};
|
||||
const delivery: Record<string, unknown> = { mode: deliveryMode };
|
||||
if (typeof opts.channel === "string") {
|
||||
const channel = opts.channel.trim();
|
||||
delivery.channel = channel ? channel : undefined;
|
||||
}
|
||||
if (typeof opts.to === "string") {
|
||||
const to = opts.to.trim();
|
||||
delivery.to = to ? to : undefined;
|
||||
}
|
||||
if (typeof opts.bestEffortDeliver === "boolean") {
|
||||
delivery.bestEffort = opts.bestEffortDeliver;
|
||||
}
|
||||
patch.delivery = delivery;
|
||||
}
|
||||
|
||||
const res = await callGatewayFromCli("cron.update", opts, {
|
||||
|
||||
Reference in New Issue
Block a user