(msg: unknown)
| 40 | |
| 41 | /** Pull file_attachments off a loosely-typed inbound message. */ |
| 42 | export function extractInboundAttachments(msg: unknown): InboundAttachment[] { |
| 43 | if (typeof msg !== 'object' || msg === null || !('file_attachments' in msg)) { |
| 44 | return [] |
| 45 | } |
| 46 | const parsed = attachmentsArraySchema().safeParse(msg.file_attachments) |
| 47 | return parsed.success ? parsed.data : [] |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Strip path components and keep only filename-safe chars. file_name comes |