jsonFrom static method
Converts a ChatMessage from dash_chat_custom into the JSON map
used to persist a chat message document/row. timestamp is supplied
by the backend so it can use its own server-time convention (e.g.
FieldValue.serverTimestamp() for Firestore, or an ISO-8601 string
for Appwrite/Supabase).
Implementation
static Map<String, dynamic> jsonFrom(ChatMessage m, Object timestamp) {
return {
"text": m.text,
"photos": (m.medias != null && m.medias!.isNotEmpty)
? m.medias!.map((e) {
return {
"url": e.url,
"type": e.type.toString(),
"fileName": e.fileName,
};
}).toList()
: [],
"userId": m.user.id,
"activityStatus": 1,
"seenStatus": 1,
"seenBy": [],
"timestamp": timestamp,
};
}