mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:40:44 +00:00
fix(gateway): preserve cron delivery validation behavior
This commit is contained in:
@@ -51,5 +51,6 @@ export interface CronServiceContract {
|
||||
run(id: string, mode?: CronRunMode): Promise<CronServiceRunResult>;
|
||||
enqueueRun(id: string, mode?: CronRunMode): Promise<CronServiceRunResult>;
|
||||
getJob(id: string): CronJob | undefined;
|
||||
getDefaultAgentId(): string | undefined;
|
||||
wake(opts: { mode: CronWakeMode; text: string }): CronWakeResult;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,10 @@ export class CronService implements CronServiceContract {
|
||||
return this.state.store?.jobs.find((job) => job.id === id);
|
||||
}
|
||||
|
||||
getDefaultAgentId(): string | undefined {
|
||||
return this.state.deps.defaultAgentId;
|
||||
}
|
||||
|
||||
wake(opts: { mode: "now" | "next-heartbeat"; text: string }) {
|
||||
return ops.wakeNow(this.state, opts);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
||||
import { listPotentialConfiguredChannelIds } from "../../channels/config-presence.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
@@ -29,6 +28,12 @@ import {
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
function listConfiguredAnnounceChannelIds(cfg: OpenClawConfig): string[] {
|
||||
return listPotentialConfiguredChannelIds(cfg, process.env, {
|
||||
includePersistedAuthState: false,
|
||||
}).filter((channelId) => cfg.channels?.[channelId]?.enabled !== false);
|
||||
}
|
||||
|
||||
function assertConfiguredAnnounceChannel(params: {
|
||||
cfg: OpenClawConfig;
|
||||
channel?: string;
|
||||
@@ -38,9 +43,7 @@ function assertConfiguredAnnounceChannel(params: {
|
||||
return;
|
||||
}
|
||||
|
||||
const configuredChannels = listPotentialConfiguredChannelIds(params.cfg, process.env, {
|
||||
includePersistedAuthState: false,
|
||||
}).toSorted();
|
||||
const configuredChannels = listConfiguredAnnounceChannelIds(params.cfg).toSorted();
|
||||
const normalizedChannel = normalizeMessageChannel(params.channel);
|
||||
if (!normalizedChannel) {
|
||||
if (configuredChannels.length <= 1) {
|
||||
@@ -90,6 +93,7 @@ function assertValidCronCreateDelivery(cfg: OpenClawConfig, jobCreate: CronJobCr
|
||||
|
||||
function assertValidCronUpdateDelivery(params: {
|
||||
cfg: OpenClawConfig;
|
||||
defaultAgentId?: string;
|
||||
currentJob: CronJob | undefined;
|
||||
patch: CronJobPatch;
|
||||
}) {
|
||||
@@ -99,7 +103,7 @@ function assertValidCronUpdateDelivery(params: {
|
||||
|
||||
const nextJob = structuredClone(params.currentJob);
|
||||
applyJobPatch(nextJob, params.patch, {
|
||||
defaultAgentId: resolveDefaultAgentId(params.cfg),
|
||||
defaultAgentId: params.defaultAgentId,
|
||||
});
|
||||
assertValidCronAnnounceDelivery({
|
||||
cfg: params.cfg,
|
||||
@@ -295,6 +299,7 @@ export const cronHandlers: GatewayRequestHandlers = {
|
||||
try {
|
||||
assertValidCronUpdateDelivery({
|
||||
cfg,
|
||||
defaultAgentId: context.cron.getDefaultAgentId(),
|
||||
currentJob: context.cron.getJob(jobId),
|
||||
patch,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user