mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:40:43 +00:00
Merged via squash.
Prepared head SHA: d34755262f
Co-authored-by: velvet-shark <126378+velvet-shark@users.noreply.github.com>
Co-authored-by: velvet-shark <126378+velvet-shark@users.noreply.github.com>
Reviewed-by: @velvet-shark
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
|
|
|
export type WhatsAppSocketTimingOptions = {
|
|
keepAliveIntervalMs?: number;
|
|
connectTimeoutMs?: number;
|
|
defaultQueryTimeoutMs?: number;
|
|
};
|
|
|
|
export const DEFAULT_WHATSAPP_SOCKET_TIMING: Required<WhatsAppSocketTimingOptions> = {
|
|
keepAliveIntervalMs: 25_000,
|
|
connectTimeoutMs: 60_000,
|
|
defaultQueryTimeoutMs: 60_000,
|
|
};
|
|
|
|
function positiveInteger(value: number | undefined): number | undefined {
|
|
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : undefined;
|
|
}
|
|
|
|
export function resolveWhatsAppSocketTiming(
|
|
cfg: OpenClawConfig,
|
|
overrides?: WhatsAppSocketTimingOptions,
|
|
): Required<WhatsAppSocketTimingOptions> {
|
|
const configured = cfg.web?.whatsapp;
|
|
return {
|
|
keepAliveIntervalMs:
|
|
positiveInteger(overrides?.keepAliveIntervalMs) ??
|
|
positiveInteger(configured?.keepAliveIntervalMs) ??
|
|
DEFAULT_WHATSAPP_SOCKET_TIMING.keepAliveIntervalMs,
|
|
connectTimeoutMs:
|
|
positiveInteger(overrides?.connectTimeoutMs) ??
|
|
positiveInteger(configured?.connectTimeoutMs) ??
|
|
DEFAULT_WHATSAPP_SOCKET_TIMING.connectTimeoutMs,
|
|
defaultQueryTimeoutMs:
|
|
positiveInteger(overrides?.defaultQueryTimeoutMs) ??
|
|
positiveInteger(configured?.defaultQueryTimeoutMs) ??
|
|
DEFAULT_WHATSAPP_SOCKET_TIMING.defaultQueryTimeoutMs,
|
|
};
|
|
}
|