diff --git a/src/config/types.ts b/src/config/types.ts index 8cfdae2e6..60cf46af1 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -131,6 +131,8 @@ export type WhatsAppConfig = { groupPolicy?: GroupPolicy; /** Outbound text chunk size (chars). Default: 4000. */ textChunkLimit?: number; + /** Maximum media file size in MB. Default: 50. */ + mediaMaxMb?: number; /** Disable block streaming for this account. */ blockStreaming?: boolean; /** Merge streamed block replies before sending. */ @@ -160,6 +162,7 @@ export type WhatsAppAccountConfig = { groupAllowFrom?: string[]; groupPolicy?: GroupPolicy; textChunkLimit?: number; + mediaMaxMb?: number; blockStreaming?: boolean; /** Merge streamed block replies before sending. */ blockStreamingCoalesce?: BlockStreamingCoalesceConfig; diff --git a/src/config/zod-schema.ts b/src/config/zod-schema.ts index ae655eb41..7c5d0fd7d 100644 --- a/src/config/zod-schema.ts +++ b/src/config/zod-schema.ts @@ -1227,6 +1227,7 @@ export const ClawdbotSchema = z.object({ groupAllowFrom: z.array(z.string()).optional(), groupPolicy: GroupPolicySchema.optional().default("open"), textChunkLimit: z.number().int().positive().optional(), + mediaMaxMb: z.number().int().positive().optional(), blockStreaming: z.boolean().optional(), blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(), groups: z @@ -1262,6 +1263,7 @@ export const ClawdbotSchema = z.object({ groupAllowFrom: z.array(z.string()).optional(), groupPolicy: GroupPolicySchema.optional().default("open"), textChunkLimit: z.number().int().positive().optional(), + mediaMaxMb: z.number().int().positive().optional().default(50), blockStreaming: z.boolean().optional(), blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(), actions: z diff --git a/src/web/inbound.ts b/src/web/inbound.ts index b8f129de1..4df694bdb 100644 --- a/src/web/inbound.ts +++ b/src/web/inbound.ts @@ -83,6 +83,7 @@ export async function monitorWebInbox(options: { accountId: string; authDir: string; onMessage: (msg: WebInboundMessage) => Promise; + mediaMaxMb?: number; }) { const inboundLogger = getChildLogger({ module: "web-inbound" }); const inboundConsoleLog = createSubsystemLogger( @@ -375,9 +376,12 @@ export async function monitorWebInbox(options: { try { const inboundMedia = await downloadInboundMedia(msg, sock); if (inboundMedia) { + const maxBytes = (options.mediaMaxMb ?? 50) * 1024 * 1024; const saved = await saveMediaBuffer( inboundMedia.buffer, inboundMedia.mimetype, + "inbound", + maxBytes, ); mediaPath = saved.path; mediaType = inboundMedia.mimetype;