( message: Record<string, unknown>, metadata?: Record<string, unknown> )
| 61 | } |
| 62 | |
| 63 | function normalizeWhatsAppMessage( |
| 64 | message: Record<string, unknown>, |
| 65 | metadata?: Record<string, unknown> |
| 66 | ) { |
| 67 | const text = isRecord(message.text) ? message.text : undefined |
| 68 | |
| 69 | return { |
| 70 | messageId: typeof message.id === 'string' ? message.id : undefined, |
| 71 | from: typeof message.from === 'string' ? message.from : undefined, |
| 72 | phoneNumberId: |
| 73 | typeof metadata?.phone_number_id === 'string' ? metadata.phone_number_id : undefined, |
| 74 | displayPhoneNumber: |
| 75 | typeof metadata?.display_phone_number === 'string' |
| 76 | ? metadata.display_phone_number |
| 77 | : undefined, |
| 78 | text: typeof text?.body === 'string' ? text.body : undefined, |
| 79 | timestamp: typeof message.timestamp === 'string' ? message.timestamp : undefined, |
| 80 | messageType: typeof message.type === 'string' ? message.type : undefined, |
| 81 | raw: message, |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | function normalizeWhatsAppStatus( |
| 86 | status: Record<string, unknown>, |
no test coverage detected