From 8b4a35e6b7cadc9bf0d773a858d8e5ed34b04a8c Mon Sep 17 00:00:00 2001 From: hrxiang Date: Thu, 7 Apr 2022 12:22:38 +0800 Subject: [PATCH] Upgrade --- CHANGELOG.md | 15 +- example/pubspec.lock | 2 +- lib/src/enum/message_type.dart | 2 + lib/src/models/group_info.dart | 4 + lib/src/models/notification_info.dart | 253 ++++++++++++++++++++++++++ lib/src/models/user_info.dart | 10 + 6 files changed, 278 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa5619c..a7457ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,13 @@ ## 2.0.0+5 -1.New oa notification
-2.New method deleteConversationMsgFromLocalAndSvr
-2.New method deleteMessageFromLocalAndSvr
-3.New method deleteAllMsgFromLocal
-3.New method deleteAllMsgFromLocalAndSvr
-3.New method markMessageAsReadByConID
-3.New method wakeUp
+1.New notification
+2.New deleteConversationMsgFromLocalAndSvr
+3.New deleteMessageFromLocalAndSvr
+4.New deleteAllMsgFromLocal
+5.New deleteAllMsgFromLocalAndSvr
+6.New markMessageAsReadByConID
+7.New wakeUp
+8.New group notification class
## 2.0.0+4 diff --git a/example/pubspec.lock b/example/pubspec.lock index 20e2a20..413f46a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -68,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "2.0.0+3" + version: "2.0.0+5" flutter_test: dependency: "direct dev" description: flutter diff --git a/lib/src/enum/message_type.dart b/lib/src/enum/message_type.dart index 68ec35c..88b68aa 100644 --- a/lib/src/enum/message_type.dart +++ b/lib/src/enum/message_type.dart @@ -61,5 +61,7 @@ class MessageType { static const signalingNotification = 1601; static const signalingNotificationEnd = 1699; + static const burnAfterReadingNotification = 1701; + static const notificationEnd = 2000; } diff --git a/lib/src/models/group_info.dart b/lib/src/models/group_info.dart index c353457..5137192 100644 --- a/lib/src/models/group_info.dart +++ b/lib/src/models/group_info.dart @@ -73,6 +73,7 @@ class GroupMembersInfo { String? operatorUserID; String? ext; int? muteEndTime; + int? appMangerLevel; GroupMembersInfo({ this.groupID, @@ -85,6 +86,7 @@ class GroupMembersInfo { this.joinSource, this.operatorUserID, this.muteEndTime, + this.appMangerLevel, }); GroupMembersInfo.fromJson(Map json) { @@ -98,6 +100,7 @@ class GroupMembersInfo { joinSource = json['joinSource']; operatorUserID = json['operatorUserID']; muteEndTime = json['muteEndTime']; + appMangerLevel = json['appMangerLevel']; } Map toJson() { @@ -112,6 +115,7 @@ class GroupMembersInfo { data['joinSource'] = this.joinSource; data['operatorUserID'] = this.operatorUserID; data['muteEndTime'] = this.muteEndTime; + data['appMangerLevel'] = this.appMangerLevel; return data; } } diff --git a/lib/src/models/notification_info.dart b/lib/src/models/notification_info.dart index 0c75197..a9fcb7f 100644 --- a/lib/src/models/notification_info.dart +++ b/lib/src/models/notification_info.dart @@ -1,6 +1,7 @@ import '../../flutter_openim_sdk.dart'; /// OA notification +/// oa 通知 class OANotification { String? notificationName; String? notificationFaceURL; @@ -79,3 +80,255 @@ class OANotification { return data; } } + +/// Group common notification +class GroupNotification { + GroupInfo? group; + GroupMembersInfo? opUser; + GroupMembersInfo? groupOwnerUser; + List? memberList; + + GroupNotification({ + this.group, + this.opUser, + this.groupOwnerUser, + this.memberList, + }); + + GroupNotification.fromJson(Map json) { + group = json['group'] != null ? GroupInfo.fromJson(json['group']) : null; + opUser = json['opUser'] != null + ? GroupMembersInfo.fromJson(json['opUser']) + : null; + groupOwnerUser = json['groupOwnerUser'] != null + ? GroupMembersInfo.fromJson(json['groupOwnerUser']) + : null; + if (json['memberList'] != null) { + memberList = []; + json['memberList'].forEach((v) { + memberList!.add(GroupMembersInfo.fromJson(v)); + }); + } + } + + Map toJson() { + final data = Map(); + if (this.group != null) { + data['group'] = this.group!.toJson(); + } + if (this.opUser != null) { + data['opUser'] = this.opUser!.toJson(); + } + if (this.groupOwnerUser != null) { + data['groupOwnerUser'] = this.groupOwnerUser!.toJson(); + } + if (this.memberList != null) { + data['memberList'] = this.memberList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +/// User is invited to the group notification +/// 用户被邀请进群通知 +class InvitedJoinGroupNotification { + GroupInfo? group; + GroupMembersInfo? opUser; + List? invitedUserList; + + InvitedJoinGroupNotification({this.group, this.opUser, this.invitedUserList}); + + InvitedJoinGroupNotification.fromJson(Map json) { + group = json['group'] != null ? GroupInfo.fromJson(json['group']) : null; + opUser = json['opUser'] != null + ? GroupMembersInfo.fromJson(json['opUser']) + : null; + if (json['invitedUserList'] != null) { + invitedUserList = []; + json['invitedUserList'].forEach((v) { + invitedUserList!.add(GroupMembersInfo.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.group != null) { + data['group'] = this.group!.toJson(); + } + if (this.opUser != null) { + data['opUser'] = this.opUser!.toJson(); + } + if (this.invitedUserList != null) { + data['invitedUserList'] = + this.invitedUserList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +/// Group kicked member notification +/// 组踢出成员通知 +class KickedGroupMemeberNotification { + GroupInfo? group; + GroupMembersInfo? opUser; + List? kickedUserList; + + KickedGroupMemeberNotification( + {this.group, this.opUser, this.kickedUserList}); + + KickedGroupMemeberNotification.fromJson(Map json) { + group = json['group'] != null ? GroupInfo.fromJson(json['group']) : null; + opUser = json['opUser'] != null + ? GroupMembersInfo.fromJson(json['opUser']) + : null; + if (json['kickedUserList'] != null) { + kickedUserList = []; + json['kickedUserList'].forEach((v) { + kickedUserList!.add(GroupMembersInfo.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.group != null) { + data['group'] = this.group!.toJson(); + } + if (this.opUser != null) { + data['opUser'] = this.opUser!.toJson(); + } + if (this.kickedUserList != null) { + data['kickedUserList'] = + this.kickedUserList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +/// Exit group notification +/// 退出群通知 +class QuitGroupNotification { + GroupInfo? group; + GroupMembersInfo? quitUser; + + QuitGroupNotification({this.group, this.quitUser}); + + QuitGroupNotification.fromJson(Map json) { + group = json['group'] != null ? GroupInfo.fromJson(json['group']) : null; + quitUser = json['quitUser'] != null + ? GroupMembersInfo.fromJson(json['quitUser']) + : null; + } + + Map toJson() { + final data = Map(); + if (this.group != null) { + data['group'] = this.group!.toJson(); + } + if (this.quitUser != null) { + data['quitUser'] = this.quitUser!.toJson(); + } + return data; + } +} + +/// Group rights transfer noticication +/// 群权转让通知 +class GroupRightsTransferNoticication { + GroupInfo? group; + GroupMembersInfo? opUser; + GroupMembersInfo? newGroupOwner; + + GroupRightsTransferNoticication({ + this.group, + this.opUser, + this.newGroupOwner, + }); + + GroupRightsTransferNoticication.fromJson(Map json) { + group = json['group'] != null ? GroupInfo.fromJson(json['group']) : null; + opUser = json['opUser'] != null + ? GroupMembersInfo.fromJson(json['opUser']) + : null; + newGroupOwner = json['newGroupOwner'] != null + ? GroupMembersInfo.fromJson(json['newGroupOwner']) + : null; + } + + Map toJson() { + final data = Map(); + if (this.group != null) { + data['group'] = this.group!.toJson(); + } + if (this.opUser != null) { + data['opUser'] = this.opUser!.toJson(); + } + if (this.newGroupOwner != null) { + data['newGroupOwner'] = this.newGroupOwner!.toJson(); + } + return data; + } +} + +/// Mute member notification +/// 禁言成员通知 +class MuteMemberNotification { + GroupInfo? group; + GroupMembersInfo? opUser; + GroupMembersInfo? mutedUser; + + MuteMemberNotification({ + this.group, + this.opUser, + this.mutedUser, + }); + + MuteMemberNotification.fromJson(Map json) { + group = json['group'] != null ? GroupInfo.fromJson(json['group']) : null; + opUser = json['opUser'] != null + ? GroupMembersInfo.fromJson(json['opUser']) + : null; + mutedUser = json['mutedUser'] != null + ? GroupMembersInfo.fromJson(json['mutedUser']) + : null; + } + + Map toJson() { + final data = Map(); + if (this.group != null) { + data['group'] = this.group!.toJson(); + } + if (this.opUser != null) { + data['opUser'] = this.opUser!.toJson(); + } + if (this.mutedUser != null) { + data['mutedUser'] = this.mutedUser!.toJson(); + } + return data; + } +} + +/// Burn after reading notification +/// 阅后即焚通知 +class BurnAfterReadingNotification { + String? recvID; + String? sendID; + bool? isPrivate; + + BurnAfterReadingNotification({this.recvID, this.sendID, this.isPrivate}); + + BurnAfterReadingNotification.fromJson(Map json) { + recvID = json['recvID']; + sendID = json['sendID']; + isPrivate = json['isPrivate']; + } + + Map toJson() { + final data = Map(); + data['recvID'] = this.recvID; + data['sendID'] = this.sendID; + data['isPrivate'] = this.isPrivate; + return data; + } +} diff --git a/lib/src/models/user_info.dart b/lib/src/models/user_info.dart index d3490fc..d387c8a 100644 --- a/lib/src/models/user_info.dart +++ b/lib/src/models/user_info.dart @@ -147,6 +147,16 @@ class UserInfo { if (value == null || value.trim().isEmpty) return null; return value; } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is UserInfo && + runtimeType == other.runtimeType && + userID == other.userID; + + @override + int get hashCode => userID.hashCode; } class PublicUserInfo {