From 0c6407aa888a8e4e0d024be0df58c36769cbf3d3 Mon Sep 17 00:00:00 2001 From: DinoLeung Date: Sat, 6 Apr 2024 16:35:36 +1030 Subject: [PATCH] updated mesage class --- lib/src/teledart/model/message.dart | 8 ++------ lib/src/telegram/model.g.dart | 24 +++++++++--------------- lib/src/telegram/models/message.dart | 22 ++++------------------ 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/lib/src/teledart/model/message.dart b/lib/src/teledart/model/message.dart index f7deb11..8c4058e 100644 --- a/lib/src/teledart/model/message.dart +++ b/lib/src/teledart/model/message.dart @@ -41,15 +41,11 @@ class TeleDartMessage extends Message { date: message.date, senderChat: message.senderChat, chat: message.chat, - forwardFrom: message.forwardFrom, - forwardFromChat: message.forwardFromChat, - forwardFromMessageId: message.forwardFromMessageId, - forwardSignature: message.forwardSignature, - forwardSenderName: message.forwardSenderName, - forwardDate: message.forwardDate, + forwardOrigin: message.forwardOrigin, isTopicMessage: message.isTopicMessage, isAutomaticForward: message.isAutomaticForward, replyToMessage: message.replyToMessage, + externalReply: message.externalReply, viaBot: message.viaBot, editDate: message.editDate, hasProtectedContent: message.hasProtectedContent, diff --git a/lib/src/telegram/model.g.dart b/lib/src/telegram/model.g.dart index c9f349c..3c6c844 100644 --- a/lib/src/telegram/model.g.dart +++ b/lib/src/telegram/model.g.dart @@ -3563,21 +3563,19 @@ Message _$MessageFromJson(Map json) => Message( : Chat.fromJson(json['sender_chat'] as Map), date: json['date'] as int, chat: Chat.fromJson(json['chat'] as Map), - forwardFrom: json['forward_from'] == null + forwardOrigin: json['forward_origin'] == null ? null - : User.fromJson(json['forward_from'] as Map), - forwardFromChat: json['forward_from_chat'] == null - ? null - : Chat.fromJson(json['forward_from_chat'] as Map), - forwardFromMessageId: json['forward_from_message_id'] as int?, - forwardSignature: json['forward_signature'] as String?, - forwardSenderName: json['forward_sender_name'] as String?, - forwardDate: json['forward_date'] as int?, + : MessageOrigin.fromJson( + json['forward_origin'] as Map), isTopicMessage: json['is_topic_message'] as bool?, isAutomaticForward: json['is_automatic_forward'] as bool?, replyToMessage: json['reply_to_message'] == null ? null : Message.fromJson(json['reply_to_message'] as Map), + externalReply: json['external_reply'] == null + ? null + : ExternalReplyInfo.fromJson( + json['external_reply'] as Map), viaBot: json['via_bot'] == null ? null : User.fromJson(json['via_bot'] as Map), @@ -3756,15 +3754,11 @@ Map _$MessageToJson(Message instance) { writeNotNull('sender_chat', instance.senderChat?.toJson()); val['date'] = instance.date; val['chat'] = instance.chat.toJson(); - writeNotNull('forward_from', instance.forwardFrom?.toJson()); - writeNotNull('forward_from_chat', instance.forwardFromChat?.toJson()); - writeNotNull('forward_from_message_id', instance.forwardFromMessageId); - writeNotNull('forward_signature', instance.forwardSignature); - writeNotNull('forward_sender_name', instance.forwardSenderName); - writeNotNull('forward_date', instance.forwardDate); + writeNotNull('forward_origin', instance.forwardOrigin?.toJson()); writeNotNull('is_topic_message', instance.isTopicMessage); writeNotNull('is_automatic_forward', instance.isAutomaticForward); writeNotNull('reply_to_message', instance.replyToMessage?.toJson()); + writeNotNull('external_reply', instance.externalReply?.toJson()); writeNotNull('via_bot', instance.viaBot?.toJson()); writeNotNull('edit_date', instance.editDate); writeNotNull('has_protected_content', instance.hasProtectedContent); diff --git a/lib/src/telegram/models/message.dart b/lib/src/telegram/models/message.dart index 16c1506..af6726b 100644 --- a/lib/src/telegram/models/message.dart +++ b/lib/src/telegram/models/message.dart @@ -29,15 +29,11 @@ class Message { Chat? senderChat; int date; Chat chat; - User? forwardFrom; - Chat? forwardFromChat; - int? forwardFromMessageId; - String? forwardSignature; - String? forwardSenderName; - int? forwardDate; + MessageOrigin? forwardOrigin; bool? isTopicMessage; bool? isAutomaticForward; Message? replyToMessage; + ExternalReplyInfo? externalReply; User? viaBot; int? editDate; bool? hasProtectedContent; @@ -103,15 +99,11 @@ class Message { this.senderChat, required this.date, required this.chat, - this.forwardFrom, - this.forwardFromChat, - this.forwardFromMessageId, - this.forwardSignature, - this.forwardSenderName, - this.forwardDate, + this.forwardOrigin, this.isTopicMessage, this.isAutomaticForward, this.replyToMessage, + this.externalReply, this.viaBot, this.editDate, this.hasProtectedContent, @@ -175,12 +167,6 @@ class Message { DateTime get date_ => TimeHelper.toDateTime(date); set date_(DateTime dateTime) => date = TimeHelper.toUnixTime(dateTime); - @JsonKey(includeFromJson: false, includeToJson: false) - DateTime? get forwardDate_ => - forwardDate == null ? null : TimeHelper.toDateTime(forwardDate!); - set forwardDate_(DateTime? dateTime) => - forwardDate = dateTime == null ? null : TimeHelper.toUnixTime(dateTime); - @JsonKey(includeFromJson: false, includeToJson: false) DateTime? get editDate_ => editDate == null ? null : TimeHelper.toDateTime(editDate!);