PG→Mongo Ingest CLI - v1.0.0
    Preparing search index...

    Function getLatestMessageMeta

    • Gets metadata about the most recent message in a specific chat.

      This function is used to determine the latest message timestamp and ID for a chat, which is useful for:

      • Setting up relative time filters (e.g., "last N days")
      • Determining the end boundary for import ranges
      • Validating cursor positions

      Parameters

      • chat_id: string

        The chat ID to get the latest message for

      Returns Promise<null | { ts_seconds: number; message_id: string }>

      Promise resolving to message metadata or null if no messages exist

      const latest = await getLatestMessageMeta("19175769740@s.whatsapp.net");
      if (latest) {
      console.log(`Latest message: ${latest.message_id} at ${new Date(latest.ts_seconds * 1000)}`);
      }