fix: telegram forward metadata + cron delivery guard (#8392) (thanks @Glucksberg)
This commit is contained in:
@@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Cron: accept epoch timestamps and 0ms durations in CLI `--at` parsing.
|
||||
- Cron: reload store data when the store file is recreated or mtime changes.
|
||||
- Cron: deliver announce runs directly, honor delivery mode, and respect wakeMode for summaries. (#8540) Thanks @tyler6204.
|
||||
- Telegram: include forward_from_chat metadata in forwarded messages and harden cron delivery target checks. (#8392) Thanks @Glucksberg.
|
||||
|
||||
## 2026.2.2-3
|
||||
|
||||
|
||||
@@ -92,18 +92,6 @@ function resolveCronDeliveryBestEffort(job: CronJob): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
function resolveCronDeliveryFailure(
|
||||
resolved: Awaited<ReturnType<typeof resolveDeliveryTarget>>,
|
||||
): Error | undefined {
|
||||
if (resolved.error) {
|
||||
return resolved.error;
|
||||
}
|
||||
if (!resolved.to) {
|
||||
return new Error("cron delivery target is missing");
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export type RunCronAgentTurnResult = {
|
||||
status: "ok" | "error" | "skipped";
|
||||
summary?: string;
|
||||
@@ -460,17 +448,29 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
);
|
||||
|
||||
if (deliveryRequested && !skipHeartbeatDelivery && !skipMessagingToolDelivery) {
|
||||
const deliveryFailure = resolveCronDeliveryFailure(resolvedDelivery);
|
||||
if (deliveryFailure) {
|
||||
if (resolvedDelivery.error) {
|
||||
if (!deliveryBestEffort) {
|
||||
return {
|
||||
status: "error",
|
||||
error: deliveryFailure.message,
|
||||
error: resolvedDelivery.error.message,
|
||||
summary,
|
||||
outputText,
|
||||
};
|
||||
}
|
||||
logWarn(`[cron:${params.job.id}] ${deliveryFailure.message}`);
|
||||
logWarn(`[cron:${params.job.id}] ${resolvedDelivery.error.message}`);
|
||||
return { status: "ok", summary, outputText };
|
||||
}
|
||||
if (!resolvedDelivery.to) {
|
||||
const message = "cron delivery target is missing";
|
||||
if (!deliveryBestEffort) {
|
||||
return {
|
||||
status: "error",
|
||||
error: message,
|
||||
summary,
|
||||
outputText,
|
||||
};
|
||||
}
|
||||
logWarn(`[cron:${params.job.id}] ${message}`);
|
||||
return { status: "ok", summary, outputText };
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -253,8 +253,6 @@ export function describeReplyTarget(msg: Message): TelegramReplyTarget | null {
|
||||
};
|
||||
}
|
||||
|
||||
export type TelegramChatType = "private" | "group" | "supergroup" | "channel";
|
||||
|
||||
export type TelegramForwardedContext = {
|
||||
from: string;
|
||||
date?: number;
|
||||
@@ -264,7 +262,7 @@ export type TelegramForwardedContext = {
|
||||
fromTitle?: string;
|
||||
fromSignature?: string;
|
||||
/** Original chat type from forward_from_chat (e.g. "channel", "supergroup", "group"). */
|
||||
fromChatType?: TelegramChatType;
|
||||
fromChatType?: Chat["type"];
|
||||
/** Original message ID in the source chat (channel forwards). */
|
||||
fromMessageId?: number;
|
||||
};
|
||||
@@ -338,7 +336,7 @@ function buildForwardedContextFromChat(params: {
|
||||
}
|
||||
const signature = params.signature?.trim() || undefined;
|
||||
const from = signature ? `${display} (${signature})` : display;
|
||||
const chatType = (params.chat.type?.trim() || undefined) as TelegramChatType | undefined;
|
||||
const chatType = (params.chat.type?.trim() || undefined) as Chat["type"] | undefined;
|
||||
return {
|
||||
from,
|
||||
date: params.date,
|
||||
|
||||
Reference in New Issue
Block a user