@@ -10,6 +10,7 @@ import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runt
|
10 | 10 | import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound"; |
11 | 11 | import { createInboundDebouncer } from "openclaw/plugin-sdk/channel-inbound-debounce"; |
12 | 12 | import { getChildLogger } from "openclaw/plugin-sdk/logging-core"; |
| 13 | +import { parseStrictFiniteNumber } from "openclaw/plugin-sdk/number-runtime"; |
13 | 14 | import { defaultRuntime } from "openclaw/plugin-sdk/runtime-env"; |
14 | 15 | import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env"; |
15 | 16 | import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime"; |
@@ -79,6 +80,17 @@ type LocalGroupMetadataCacheEntry = WhatsAppGroupMetadataCacheEntry & {
|
79 | 80 | mentionParticipants?: WhatsAppOutboundMentionParticipant[]; |
80 | 81 | }; |
81 | 82 | |
| 83 | +function parseWhatsAppTimestampSeconds(value: unknown): number | undefined { |
| 84 | +if (value == null) { |
| 85 | +return undefined; |
| 86 | +} |
| 87 | +if (typeof value === "string") { |
| 88 | +return parseStrictFiniteNumber(value); |
| 89 | +} |
| 90 | +const parsed = Number(value); |
| 91 | +return Number.isFinite(parsed) ? parsed : undefined; |
| 92 | +} |
| 93 | + |
82 | 94 | function rememberGroupMetadataCacheEntry<T extends WhatsAppGroupMetadataCacheEntry>( |
83 | 95 | cache: Map<string, T>, |
84 | 96 | jid: string, |
@@ -614,9 +626,9 @@ export async function attachWebInboxToSocket(
|
614 | 626 | groupSubject = meta.subject; |
615 | 627 | groupParticipants = meta.participants; |
616 | 628 | } |
617 | | -const messageTimestampMs = msg.messageTimestamp |
618 | | - ? Number(msg.messageTimestamp) * 1000 |
619 | | - : undefined; |
| 629 | +const messageTimestampSeconds = parseWhatsAppTimestampSeconds(msg.messageTimestamp); |
| 630 | +const messageTimestampMs = |
| 631 | +messageTimestampSeconds !== undefined ? messageTimestampSeconds * 1000 : undefined; |
620 | 632 | |
621 | 633 | const accessCfg = options.loadConfig?.() ?? options.cfg; |
622 | 634 | const access = await checkInboundAccessControl({ |
@@ -740,9 +752,8 @@ export async function attachWebInboxToSocket(
|
740 | 752 | return false; |
741 | 753 | } |
742 | 754 | const APPEND_RECENT_GRACE_MS = 60_000; |
743 | | -const msgTsRaw = msg.messageTimestamp; |
744 | | -const msgTsNum = msgTsRaw != null ? Number(msgTsRaw) : Number.NaN; |
745 | | -const msgTsMs = Number.isFinite(msgTsNum) ? msgTsNum * 1000 : 0; |
| 755 | +const msgTsSeconds = parseWhatsAppTimestampSeconds(msg.messageTimestamp); |
| 756 | +const msgTsMs = msgTsSeconds !== undefined ? msgTsSeconds * 1000 : 0; |
746 | 757 | return msgTsMs < connectedAtMs - APPEND_RECENT_GRACE_MS; |
747 | 758 | }; |
748 | 759 | |
|