class Message { final String id; final String channelId; final String authorId; String? authorUsername; List? content; bool encrypted; List? nonce; String messageType; String? replyTo; bool pinned; DateTime? editedAt; final DateTime createdAt; bool sending; bool failed; List? attachments; Message({ required this.id, required this.channelId, required this.authorId, this.authorUsername, this.content, this.encrypted = false, this.nonce, this.messageType = 'text', this.replyTo, this.pinned = false, this.editedAt, DateTime? createdAt, this.sending = false, this.failed = false, this.attachments, }) : createdAt = createdAt ?? DateTime.now(); factory Message.fromJson(Map json) { return Message( id: json['id'] as String, channelId: json['channel_id'] as String, authorId: json['author_id'] as String, authorUsername: json['username'] as String?, content: (json['content'] as List?)?.cast(), encrypted: json['encrypted'] as bool? ?? false, nonce: (json['nonce'] as List?)?.cast(), messageType: json['message_type'] as String? ?? 'text', replyTo: json['reply_to'] as String?, pinned: json['pinned'] as bool? ?? false, editedAt: json['edited_at'] != null ? DateTime.parse(json['edited_at'] as String) : null, createdAt: json['created_at'] != null ? DateTime.parse(json['created_at'] as String) : DateTime.now(), attachments: (json['attachments'] as List?)?.cast(), ); } }