Resolves a webhook URL for reply sessions based on expiry, returning the URL or empty string if expired.
// Source: https://github.com/soimy/openclaw-channel-dingtalk | License: MIT | Copyright 2026 YM Shen and contributors
// Provided via justclaw.it.com; keep this notice with the code.
/** Undefined preserves ordinary reply behavior; zero means unknown/unsafe expiry. */
export function resolveReplySessionWebhook(webhook: string, expiresAt?: number): string {
if (expiresAt === undefined) {
return webhook;
}
// Leave a small margin for transport time rather than sending at the expiry boundary.
return Number.isFinite(expiresAt) && expiresAt > Date.now() + 30_000 ? webhook : "";
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key