fix: telegram forward metadata + cron delivery guard (#8392) (thanks @Glucksberg)
parent
b2361292e7
commit
78fd194722
|
|
@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai
|
||||||
- Cron: accept epoch timestamps and 0ms durations in CLI `--at` parsing.
|
- 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: 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.
|
- 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
|
## 2026.2.2-3
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,18 +92,6 @@ function resolveCronDeliveryBestEffort(job: CronJob): boolean {
|
||||||
return false;
|
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 = {
|
export type RunCronAgentTurnResult = {
|
||||||
status: "ok" | "error" | "skipped";
|
status: "ok" | "error" | "skipped";
|
||||||
summary?: string;
|
summary?: string;
|
||||||
|
|
@ -460,17 +448,29 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (deliveryRequested && !skipHeartbeatDelivery && !skipMessagingToolDelivery) {
|
if (deliveryRequested && !skipHeartbeatDelivery && !skipMessagingToolDelivery) {
|
||||||
const deliveryFailure = resolveCronDeliveryFailure(resolvedDelivery);
|
if (resolvedDelivery.error) {
|
||||||
if (deliveryFailure) {
|
|
||||||
if (!deliveryBestEffort) {
|
if (!deliveryBestEffort) {
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
error: deliveryFailure.message,
|
error: resolvedDelivery.error.message,
|
||||||
summary,
|
summary,
|
||||||
outputText,
|
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 };
|
return { status: "ok", summary, outputText };
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -253,8 +253,6 @@ export function describeReplyTarget(msg: Message): TelegramReplyTarget | null {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TelegramChatType = "private" | "group" | "supergroup" | "channel";
|
|
||||||
|
|
||||||
export type TelegramForwardedContext = {
|
export type TelegramForwardedContext = {
|
||||||
from: string;
|
from: string;
|
||||||
date?: number;
|
date?: number;
|
||||||
|
|
@ -264,7 +262,7 @@ export type TelegramForwardedContext = {
|
||||||
fromTitle?: string;
|
fromTitle?: string;
|
||||||
fromSignature?: string;
|
fromSignature?: string;
|
||||||
/** Original chat type from forward_from_chat (e.g. "channel", "supergroup", "group"). */
|
/** 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). */
|
/** Original message ID in the source chat (channel forwards). */
|
||||||
fromMessageId?: number;
|
fromMessageId?: number;
|
||||||
};
|
};
|
||||||
|
|
@ -338,7 +336,7 @@ function buildForwardedContextFromChat(params: {
|
||||||
}
|
}
|
||||||
const signature = params.signature?.trim() || undefined;
|
const signature = params.signature?.trim() || undefined;
|
||||||
const from = signature ? `${display} (${signature})` : display;
|
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 {
|
return {
|
||||||
from,
|
from,
|
||||||
date: params.date,
|
date: params.date,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue