Function
parseMetadata
(metadataJson?: string | null)
Source from the content-addressed store, hash-verified
| 3 | import type { RealtimeMessage } from '@/types'; |
| 4 | |
| 5 | function parseMetadata(metadataJson?: string | null): MessageMetadata | null { |
| 6 | if (!metadataJson) { |
| 7 | return null; |
| 8 | } |
| 9 | |
| 10 | try { |
| 11 | const parsed = JSON.parse(metadataJson) as MessageMetadata; |
| 12 | return parsed; |
| 13 | } catch (error) { |
| 14 | console.warn('[chat-serializer] Failed to parse metadata JSON:', error); |
| 15 | return null; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | export function serializeMessage( |
| 20 | message: Message, |
Tested by
no test coverage detected