From 0ef41147fd824baa905421b86a64bcd12962248e Mon Sep 17 00:00:00 2001 From: Brett <> Date: Wed, 1 Nov 2023 12:09:33 +0800 Subject: [PATCH] add 'localEx' --- lib/src/models/message.dart | 159 ++++++++++-------------------------- 1 file changed, 41 insertions(+), 118 deletions(-) diff --git a/lib/src/models/message.dart b/lib/src/models/message.dart index 81893f0..a837976 100644 --- a/lib/src/models/message.dart +++ b/lib/src/models/message.dart @@ -42,8 +42,8 @@ class Message { /// Group ID. String? groupID; - /// Message content. -// String? content; + /// Message localEx. + String? localEx; /// Message sequence number. int? seq; @@ -137,7 +137,7 @@ class Message { this.senderNickname, this.senderFaceUrl, this.groupID, - // this.content, + this.localEx, this.seq, this.isRead, this.hasReadTime, @@ -179,65 +179,35 @@ class Message { senderNickname = json['senderNickname']; senderFaceUrl = json['senderFaceUrl']; groupID = json['groupID']; - // content = json['content']; + localEx = json['localEx']; seq = json['seq']; isRead = json['isRead']; status = json['status']; - offlinePush = json['offlinePush'] != null - ? OfflinePushInfo.fromJson(json['offlinePush']) - : null; + offlinePush = json['offlinePush'] != null ? OfflinePushInfo.fromJson(json['offlinePush']) : null; attachedInfo = json['attachedInfo']; ex = json['ex']; exMap = json['exMap'] ?? {}; sessionType = json['sessionType']; - pictureElem = json['pictureElem'] != null - ? PictureElem.fromJson(json['pictureElem']) - : null; - soundElem = json['soundElem'] != null - ? SoundElem.fromJson(json['soundElem']) - : null; - videoElem = json['videoElem'] != null - ? VideoElem.fromJson(json['videoElem']) - : null; - fileElem = - json['fileElem'] != null ? FileElem.fromJson(json['fileElem']) : null; - atTextElem = json['atTextElem'] != null - ? AtTextElem.fromJson(json['atTextElem']) - : null; - locationElem = json['locationElem'] != null - ? LocationElem.fromJson(json['locationElem']) - : null; - - customElem = json['customElem'] != null - ? CustomElem.fromJson(json['customElem']) - : null; - quoteElem = json['quoteElem'] != null - ? QuoteElem.fromJson(json['quoteElem']) - : null; - mergeElem = json['mergeElem'] != null - ? MergeElem.fromJson(json['mergeElem']) - : null; - notificationElem = json['notificationElem'] != null - ? NotificationElem.fromJson(json['notificationElem']) - : null; - faceElem = - json['faceElem'] != null ? FaceElem.fromJson(json['faceElem']) : null; - attachedInfoElem = json['attachedInfoElem'] != null - ? AttachedInfoElem.fromJson(json['attachedInfoElem']) - : null; + pictureElem = json['pictureElem'] != null ? PictureElem.fromJson(json['pictureElem']) : null; + soundElem = json['soundElem'] != null ? SoundElem.fromJson(json['soundElem']) : null; + videoElem = json['videoElem'] != null ? VideoElem.fromJson(json['videoElem']) : null; + fileElem = json['fileElem'] != null ? FileElem.fromJson(json['fileElem']) : null; + atTextElem = json['atTextElem'] != null ? AtTextElem.fromJson(json['atTextElem']) : null; + locationElem = json['locationElem'] != null ? LocationElem.fromJson(json['locationElem']) : null; + + customElem = json['customElem'] != null ? CustomElem.fromJson(json['customElem']) : null; + quoteElem = json['quoteElem'] != null ? QuoteElem.fromJson(json['quoteElem']) : null; + mergeElem = json['mergeElem'] != null ? MergeElem.fromJson(json['mergeElem']) : null; + notificationElem = json['notificationElem'] != null ? NotificationElem.fromJson(json['notificationElem']) : null; + faceElem = json['faceElem'] != null ? FaceElem.fromJson(json['faceElem']) : null; + attachedInfoElem = json['attachedInfoElem'] != null ? AttachedInfoElem.fromJson(json['attachedInfoElem']) : null; hasReadTime = json['hasReadTime'] ?? attachedInfoElem?.hasReadTime; isExternalExtensions = json['isExternalExtensions']; isReact = json['isReact']; - textElem = - json['textElem'] != null ? TextElem.fromJson(json['textElem']) : null; - cardElem = - json['cardElem'] != null ? CardElem.fromJson(json['cardElem']) : null; - advancedTextElem = json['advancedTextElem'] != null - ? AdvancedTextElem.fromJson(json['advancedTextElem']) - : null; - typingElem = json['typingElem'] != null - ? TypingElem.fromJson(json['typingElem']) - : null; + textElem = json['textElem'] != null ? TextElem.fromJson(json['textElem']) : null; + cardElem = json['cardElem'] != null ? CardElem.fromJson(json['cardElem']) : null; + advancedTextElem = json['advancedTextElem'] != null ? AdvancedTextElem.fromJson(json['advancedTextElem']) : null; + typingElem = json['typingElem'] != null ? TypingElem.fromJson(json['typingElem']) : null; } Map toJson() { @@ -254,7 +224,7 @@ class Message { data['senderNickname'] = this.senderNickname; data['senderFaceUrl'] = this.senderFaceUrl; data['groupID'] = this.groupID; - // data['content'] = this.content; + data['localEx'] = this.localEx; data['seq'] = this.seq; data['isRead'] = this.isRead; data['hasReadTime'] = this.hasReadTime; @@ -287,10 +257,7 @@ class Message { @override bool operator ==(Object other) => - identical(this, other) || - other is Message && - runtimeType == other.runtimeType && - clientMsgID == other.clientMsgID; + identical(this, other) || other is Message && runtimeType == other.runtimeType && clientMsgID == other.clientMsgID; @override int get hashCode => clientMsgID.hashCode; @@ -340,9 +307,7 @@ class Message { bool get isSingleChat => sessionType == ConversationType.single; /// Group chat message - bool get isGroupChat => - sessionType == ConversationType.group || - sessionType == ConversationType.superGroup; + bool get isGroupChat => sessionType == ConversationType.group || sessionType == ConversationType.superGroup; } /// Image message content @@ -359,23 +324,13 @@ class PictureElem { /// Thumbnail picture object PictureInfo? snapshotPicture; - PictureElem( - {this.sourcePath, - this.sourcePicture, - this.bigPicture, - this.snapshotPicture}); + PictureElem({this.sourcePath, this.sourcePicture, this.bigPicture, this.snapshotPicture}); PictureElem.fromJson(Map json) { sourcePath = json['sourcePath']; - sourcePicture = json['sourcePicture'] != null - ? new PictureInfo.fromJson(json['sourcePicture']) - : null; - bigPicture = json['bigPicture'] != null - ? new PictureInfo.fromJson(json['bigPicture']) - : null; - snapshotPicture = json['snapshotPicture'] != null - ? new PictureInfo.fromJson(json['snapshotPicture']) - : null; + sourcePicture = json['sourcePicture'] != null ? new PictureInfo.fromJson(json['sourcePicture']) : null; + bigPicture = json['bigPicture'] != null ? new PictureInfo.fromJson(json['bigPicture']) : null; + snapshotPicture = json['snapshotPicture'] != null ? new PictureInfo.fromJson(json['snapshotPicture']) : null; } Map toJson() { @@ -414,8 +369,7 @@ class PictureInfo { /// Image URL String? url; - PictureInfo( - {this.uuid, this.type, this.size, this.width, this.height, this.url}); + PictureInfo({this.uuid, this.type, this.size, this.width, this.height, this.url}); PictureInfo.fromJson(Map json) { uuid = json['uuid']; @@ -455,12 +409,7 @@ class SoundElem { /// Duration in seconds int? duration; - SoundElem( - {this.uuid, - this.soundPath, - this.sourceUrl, - this.dataSize, - this.duration}); + SoundElem({this.uuid, this.soundPath, this.sourceUrl, this.dataSize, this.duration}); SoundElem.fromJson(Map json) { uuid = json['uuid']; @@ -583,8 +532,7 @@ class FileElem { /// File size int? fileSize; - FileElem( - {this.filePath, this.uuid, this.sourceUrl, this.fileName, this.fileSize}); + FileElem({this.filePath, this.uuid, this.sourceUrl, this.fileName, this.fileSize}); FileElem.fromJson(Map json) { filePath = json['filePath']; @@ -637,13 +585,9 @@ class AtTextElem { } isAtSelf = json['isAtSelf']; if (json['atUsersInfo'] is List) { - atUsersInfo = (json['atUsersInfo'] as List) - .map((e) => AtUserInfo.fromJson(e)) - .toList(); + atUsersInfo = (json['atUsersInfo'] as List).map((e) => AtUserInfo.fromJson(e)).toList(); } - quoteMessage = null != json['quoteMessage'] - ? Message.fromJson(json['quoteMessage']) - : null; + quoteMessage = null != json['quoteMessage'] ? Message.fromJson(json['quoteMessage']) : null; } Map toJson() { @@ -766,9 +710,7 @@ class MergeElem { abstractList = json['abstractList'].cast(); } if (json['multiMessage'] is List) { - multiMessage = (json['multiMessage'] as List) - .map((e) => Message.fromJson(e)) - .toList(); + multiMessage = (json['multiMessage'] as List).map((e) => Message.fromJson(e)).toList(); } } @@ -854,9 +796,7 @@ class AttachedInfoElem { }); AttachedInfoElem.fromJson(Map json) { - groupHasReadInfo = json['groupHasReadInfo'] == null - ? null - : GroupHasReadInfo.fromJson(json['groupHasReadInfo']); + groupHasReadInfo = json['groupHasReadInfo'] == null ? null : GroupHasReadInfo.fromJson(json['groupHasReadInfo']); isPrivateChat = json['isPrivateChat']; hasReadTime = json['hasReadTime']; burnDuration = json['burnDuration']; @@ -939,18 +879,13 @@ class AdvancedTextElem { AdvancedTextElem.fromJson(Map json) { text = json['text']; - messageEntityList = json['messageEntityList'] == null - ? null - : (json['messageEntityList'] as List) - .map((e) => MessageEntity.fromJson(e)) - .toList(); + messageEntityList = json['messageEntityList'] == null ? null : (json['messageEntityList'] as List).map((e) => MessageEntity.fromJson(e)).toList(); } Map toJson() { final data = Map(); data['text'] = text; - data['messageEntityList'] = - messageEntityList?.map((e) => e.toJson()).toList(); + data['messageEntityList'] = messageEntityList?.map((e) => e.toJson()).toList(); return data; } } @@ -1036,14 +971,7 @@ class ReadReceiptInfo { /// Conversation type [ConversationType] int? sessionType; - ReadReceiptInfo( - {this.userID, - this.groupID, - this.msgIDList, - this.readTime, - this.msgFrom, - this.contentType, - this.sessionType}); + ReadReceiptInfo({this.userID, this.groupID, this.msgIDList, this.readTime, this.msgFrom, this.contentType, this.sessionType}); ReadReceiptInfo.fromJson(Map json) { userID = json['uid'] ?? json['userID']; @@ -1086,8 +1014,7 @@ class OfflinePushInfo { /// iOS-specific bool? iOSBadgeCount; - OfflinePushInfo( - {this.title, this.desc, this.ex, this.iOSPushSound, this.iOSBadgeCount}); + OfflinePushInfo({this.title, this.desc, this.ex, this.iOSPushSound, this.iOSBadgeCount}); OfflinePushInfo.fromJson(Map json) { title = json['title']; @@ -1215,11 +1142,7 @@ class AdvancedMessage { }); AdvancedMessage.fromJson(Map json) { - messageList = json['messageList'] == null - ? null - : (json['messageList'] as List) - .map((e) => Message.fromJson(e)) - .toList(); + messageList = json['messageList'] == null ? null : (json['messageList'] as List).map((e) => Message.fromJson(e)).toList(); isEnd = json['isEnd']; errCode = json['errCode']; errMsg = json['errMsg'];