convertMessage2Dart static method
Future<V2TimMessage>
convertMessage2Dart(
- dynamic jsonMessage
)
Implementation
static Future<V2TimMessage> convertMessage2Dart(jsonMessage) async {
// late String? friendRemark;
// late String? ;
Map<String, dynamic> map = Map.from({
"nickName": (Map<String, dynamic>.from(jsonMessage["message_sender_profile"] ?? {}))["user_profile_nick_name"],
"faceUrl": Map<String, dynamic>.from(jsonMessage["message_sender_profile"] ?? {})["user_profile_face_url"],
"nameCard": Map<String, dynamic>.from(jsonMessage["message_sender_group_member_info"] ?? {})["group_member_info_name_card"],
"friendRemark": Map<String, dynamic>.from(jsonMessage["message_sender_group_member_info"] ?? {})["group_member_info_remark"],
"msgID": jsonMessage["message_msg_id"],
"timestamp": jsonMessage["message_server_time"],
"sender": jsonMessage["message_sender"],
"groupID": jsonMessage["message_conv_type"] == 2 ? jsonMessage["message_conv_id"] : "",
"userID": jsonMessage["message_conv_type"] == 1 ? jsonMessage["message_conv_id"] : "",
"status": jsonMessage["message_status"],
"elemType": jsonMessage["message_elem_array"] != null
? jsonMessage["message_elem_array"][0] != null
? messageElemType2DartMessageElemType(jsonMessage["message_elem_array"][0]["elem_type"])
: null
: 0,
"localCustomData": jsonMessage["message_custom_str"],
"localCustomInt": jsonMessage["message_custom_int"],
"cloudCustomData": jsonMessage["message_cloud_custom_str"],
"isSelf": jsonMessage["message_is_from_self"],
"isRead": jsonMessage["message_is_read"],
"isPeerRead": jsonMessage["message_is_peer_read"],
"priority": jsonMessage["message_priority"] != null ? messagePriority2Dart(jsonMessage["message_priority"]) : null,
"groupAtUserList": jsonMessage["message_group_at_user_array"],
"seq": jsonMessage["message_seq"].toString(),
"random": jsonMessage["message_rand"],
"isExcludedFromUnreadCount": jsonMessage["message_is_excluded_from_unread_count"],
"isExcludedFromLastMessage": jsonMessage["message_excluded_from_last_message"],
"needReadReceipt": jsonMessage["message_need_read_receipt"],
"isSupportMessageExtension": jsonMessage["message_support_message_extension"],
"isExcludedFromContentModeration": jsonMessage["message_excluded_from_content_moderation"],
"revokeReason": jsonMessage["message_revoke_reason"],
"revokerInfo": V2TimUserFullInfo.fromJson({
"userID": jsonMessage["message_revoker_user_id"],
"nickName": jsonMessage["message_revoker_nick_name"],
"faceUrl": jsonMessage["message_revoker_face_url"],
}).toJson(),
"isBroadcastMessage": jsonMessage["message_is_broadcast_message"],
"hasRiskContent": jsonMessage["message_has_risk_content"],
"offlinePushInfo": jsonMessage["message_offline_push_config"] != null ? offLinePushConfig2Dart(jsonMessage["message_offline_push_config"]).toJson() : null,
});
if (jsonMessage["message_elem_array"] != null) {
map.addAll(await convertElemMsg2Dart(jsonMessage["message_elem_array"][0]));
}
return V2TimMessage.fromJson(map);
}