From 8d20edb02810aac846cbe81f84c12371d44b180c Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 29 Nov 2025 05:29:29 +0000 Subject: [PATCH] Simplify timestampPrefix: bool or timezone string, default true - timestampPrefix: true (UTC), false (off), or 'America/New_York' - Removed separate timestampTimezone option - Default is now enabled (true/UTC) unless explicitly false --- README.md | 3 +-- src/config/config.ts | 6 ++---- src/web/auto-reply.ts | 9 ++++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fc22cab6d..70cd06569 100644 --- a/README.md +++ b/README.md @@ -169,8 +169,7 @@ warelay supports running on the same phone number you message from—you chat wi | `inbound.allowFrom` | `string[]` (default: empty) | E.164 numbers allowed to trigger auto-reply (no `whatsapp:`); `"*"` allows any sender. | | `inbound.messagePrefix` | `string` (default: `"[warelay]"` if no allowFrom, else `""`) | Prefix added to all inbound messages before passing to command. | | `inbound.responsePrefix` | `string` (default: —) | Prefix auto-added to all outbound replies (e.g., `"🦞"`). | -| `inbound.timestampPrefix` | `boolean` (default: `false`) | Prepend compact timestamp `[Nov 29 06:30]` to messages. | -| `inbound.timestampTimezone` | `string` (default: `"UTC"`) | IANA timezone for timestamp (e.g., `"Europe/Vienna"`). | +| `inbound.timestampPrefix` | `boolean \| string` (default: `true`) | Timestamp prefix: `true` (UTC), `false` (disabled), or IANA timezone like `"Europe/Vienna"`. | | `inbound.reply.mode` | `"text"` \| `"command"` (default: —) | Reply style. | | `inbound.reply.text` | `string` (default: —) | Used when `mode=text`; templating supported. | | `inbound.reply.command` | `string[]` (default: —) | Argv for `mode=command`; each element templated. Stdout (trimmed) is sent. | diff --git a/src/config/config.ts b/src/config/config.ts index fbadf4cab..f0e46c6c4 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -48,8 +48,7 @@ export type WarelayConfig = { allowFrom?: string[]; // E.164 numbers allowed to trigger auto-reply (without whatsapp:) messagePrefix?: string; // Prefix added to all inbound messages (default: "[warelay]" if no allowFrom, else "") responsePrefix?: string; // Prefix auto-added to all outbound replies (e.g., "🦞") - timestampPrefix?: boolean; // Prepend compact timestamp to messages (default: false) - timestampTimezone?: string; // IANA timezone for timestamp (default: UTC), e.g., "Europe/Vienna" + timestampPrefix?: boolean | string; // true/false or IANA timezone string (default: true with UTC) transcribeAudio?: { // Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout. command: string[]; @@ -145,8 +144,7 @@ const WarelaySchema = z.object({ allowFrom: z.array(z.string()).optional(), messagePrefix: z.string().optional(), responsePrefix: z.string().optional(), - timestampPrefix: z.boolean().optional(), - timestampTimezone: z.string().optional(), + timestampPrefix: z.union([z.boolean(), z.string()]).optional(), transcribeAudio: z .object({ command: z.array(z.string()), diff --git a/src/web/auto-reply.ts b/src/web/auto-reply.ts index f67053b44..1edaf0165 100644 --- a/src/web/auto-reply.ts +++ b/src/web/auto-reply.ts @@ -562,10 +562,13 @@ export async function monitorWebProvider( lastInboundMsg = msg; - // Build timestamp prefix if enabled + // Build timestamp prefix (default: enabled with UTC) + // Can be: true (UTC), false (disabled), or "America/New_York" (custom timezone) let timestampStr = ""; - if (cfg.inbound?.timestampPrefix) { - const tz = cfg.inbound?.timestampTimezone ?? "UTC"; + const tsCfg = cfg.inbound?.timestampPrefix; + const tsEnabled = tsCfg !== false; // default true + if (tsEnabled) { + const tz = typeof tsCfg === "string" ? tsCfg : "UTC"; const now = new Date(); try { // Format: "Nov 29 06:30" - compact but informative