UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

28 lines (27 loc) • 864 B
//#region src/infra/channel-activity.ts const activity = /* @__PURE__ */ new Map(); function keyFor(e) { const t = e.accountId?.trim() || "default"; return `${e.channel}:${t}`; } /** Records the latest inbound or outbound activity timestamp for a channel/account. */ function recordChannelActivity(e) { const t = typeof e.at === "number" ? e.at : Date.now(); const n = keyFor(e); const r = activity.get(n) ?? { inboundAt: null, outboundAt: null }; activity.set(n, r); if (e.direction === "inbound") r.inboundAt = t; if (e.direction === "outbound") r.outboundAt = t; } /** Returns the latest known inbound/outbound activity timestamps for a channel/account. */ function getChannelActivity(e) { return activity.get(keyFor(e)) ?? { inboundAt: null, outboundAt: null }; } //#endregion export { recordChannelActivity as n, getChannelActivity as t };