This commit is contained in:
hrxiang
2022-04-01 18:25:52 +08:00
parent 57340e52a7
commit 71897bcb4e
20 changed files with 276 additions and 40 deletions

View File

@@ -25,6 +25,7 @@ export 'src/manager/im_user_manager.dart';
export 'src/models/conversation_info.dart';
export 'src/models/group_info.dart';
export 'src/models/message.dart';
export 'src/models/notification_info.dart';
export 'src/models/search_info.dart';
export 'src/models/signaling_info.dart';
export 'src/models/user_info.dart';

View File

@@ -1,4 +1,5 @@
class ConversationType {
static const single = 1;
static const group = 2;
static const notification = 4;
}

View File

@@ -36,6 +36,8 @@ class MessageType {
static const userInfoUpdatedNotification = 1303;
static const userNotificationEnd = 1399;
static const oaNotification = 1400;
static const groupNotificationBegin = 1500;
static const groupCreatedNotification = 1501;
static const groupInfoSetNotification = 1502;

View File

@@ -219,6 +219,19 @@ class ConversationManager {
"operationID": Utils.checkOperationID(operationID),
}));
/// Delete conversation from local and service
/// 删除会话
Future<dynamic> deleteConversationMsgFromLocalAndSvr({
required String conversationID,
String? operationID,
}) =>
_channel.invokeMethod(
'deleteConversationMsgFromLocalAndSvr',
_buildParam({
"conversationID": conversationID,
"operationID": Utils.checkOperationID(operationID),
}));
/// Custom sort for conversation list
/// 会话列表自定义排序规则。
List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list

View File

@@ -355,6 +355,13 @@ class IMManager {
/// 获取当前登录用户信息
Future<UserInfo> getLoginUserInfo() async => uInfo;
/// wakeup
Future wakeUp({String? operationID}) => _channel.invokeMethod(
'wakeUp',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}));
static Map _buildParam(Map param) {
param["ManagerName"] = "imManager";
return param;

View File

@@ -56,10 +56,12 @@ class MessageManager {
/// Find all history message
/// 获取聊天记录
/// [userID]接收消息的用户id
/// [conversationID] 会话id查询通知是可用
/// [groupID]接收消息的组id
Future<List<Message>> getHistoryMessageList({
String? userID,
String? groupID,
String? conversationID,
Message? startMsg,
int? count,
String? operationID,
@@ -70,6 +72,7 @@ class MessageManager {
_buildParam({
'userID': userID ?? '',
'groupID': groupID ?? '',
'conversationID': conversationID ?? '',
'startClientMsgID': startMsg?.clientMsgID ?? '',
'count': count ?? 10,
'operationID': Utils.checkOperationID(operationID),
@@ -566,6 +569,56 @@ class MessageManager {
.then((value) =>
Utils.toObj(value, (map) => SearchResult.fromJson(map)));
/// Delete message from local and service
/// 删除消息
Future<dynamic> deleteMessageFromLocalAndSvr({
required Message message,
String? operationID,
}) =>
_channel.invokeMethod(
'deleteMessageFromLocalAndSvr',
_buildParam(message.toJson()
..addAll({
"operationID": Utils.checkOperationID(operationID),
})));
/// Delete all message from local
/// 删除所有消息
Future<dynamic> deleteAllMsgFromLocal({
String? operationID,
}) =>
_channel.invokeMethod(
'deleteAllMsgFromLocal',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}));
/// Delete all message from service
/// 删除所有消息
Future<dynamic> deleteAllMsgFromLocalAndSvr({
String? operationID,
}) =>
_channel.invokeMethod(
'deleteAllMsgFromLocalAndSvr',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}));
/// Mark conversation message as read
/// 标记消息已读
Future markMessageAsReadByConID({
required String conversationID,
required List<String> messageIDList,
String? operationID,
}) =>
_channel.invokeMethod(
'markMessageAsReadByConID',
_buildParam({
"messageIDList": messageIDList,
"conversationID": conversationID,
"operationID": Utils.checkOperationID(operationID),
}));
static Map _buildParam(Map param) {
param["ManagerName"] = "messageManager";
return param;

View File

@@ -19,6 +19,7 @@ class Message {
String? content;
int? seq;
bool? isRead;
int? hasReadTime;
/// [MessageStatus]
int? status;
@@ -56,6 +57,7 @@ class Message {
this.content,
this.seq,
this.isRead,
this.hasReadTime,
this.status,
this.offlinePush,
this.attachedInfo,
@@ -132,6 +134,7 @@ class Message {
attachedInfoElem = json['attachedInfoElem'] != null
? AttachedInfoElem.fromJson(json['attachedInfoElem'])
: null;
hasReadTime = json['hasReadTime'] ?? attachedInfoElem?.hasReadTime;
}
Map<String, dynamic> toJson() {
@@ -151,6 +154,7 @@ class Message {
data['content'] = this.content;
data['seq'] = this.seq;
data['isRead'] = this.isRead;
data['hasReadTime'] = this.hasReadTime;
data['status'] = this.status;
data['offlinePush'] = this.offlinePush?.toJson();
data['attachedInfo'] = this.attachedInfo;
@@ -198,6 +202,7 @@ class Message {
content = message.content;
seq = message.seq;
isRead = message.isRead;
hasReadTime = message.hasReadTime;
status = message.status;
offlinePush = message.offlinePush;
attachedInfo = message.attachedInfo;
@@ -581,21 +586,30 @@ class FaceElem {
class AttachedInfoElem {
GroupHasReadInfo? groupHasReadInfo;
bool? isPrivateChat;
AttachedInfoElem({this.groupHasReadInfo, this.isPrivateChat});
/// 单聊有效
bool? isPrivateChat;
int? hasReadTime;
AttachedInfoElem({
this.groupHasReadInfo,
this.isPrivateChat,
this.hasReadTime,
});
AttachedInfoElem.fromJson(Map<String, dynamic> json) {
groupHasReadInfo = json['groupHasReadInfo'] == null
? null
: GroupHasReadInfo.fromJson(json['groupHasReadInfo']);
isPrivateChat = json['isPrivateChat'];
hasReadTime = json['hasReadTime'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['groupHasReadInfo'] = this.groupHasReadInfo?.toJson();
data['isPrivateChat'] = this.isPrivateChat;
data['hasReadTime'] = this.hasReadTime;
return data;
}
}

View File

@@ -0,0 +1,81 @@
import '../../flutter_openim_sdk.dart';
/// OA notification
class OANotification {
String? notificationName;
String? notificationFaceURL;
int? notificationType;
String? text;
String? externalUrl;
/// Notification Mix Type
/// 0: Plain text notification
/// 1: Text+picture notification
/// 2: Text+video notification
/// 3: Text+file notification
/// 0纯文字通知 1文字+图片通知 2文字+视频通知 3文字+文件通知
int? mixType;
PictureElem? pictureElem;
SoundElem? soundElem;
VideoElem? videoElem;
FileElem? fileElem;
String? ex;
OANotification(
{this.notificationName,
this.notificationFaceURL,
this.notificationType,
this.text,
this.externalUrl,
this.mixType,
this.pictureElem,
this.soundElem,
this.videoElem,
this.fileElem,
this.ex});
OANotification.fromJson(Map<String, dynamic> json) {
notificationName = json['notificationName'];
notificationFaceURL = json['notificationFaceURL'];
notificationType = json['notificationType'];
text = json['text'];
externalUrl = json['externalUrl'];
mixType = json['mixType'];
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;
ex = json['ex'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['notificationName'] = this.notificationName;
data['notificationFaceURL'] = this.notificationFaceURL;
data['notificationType'] = this.notificationType;
data['text'] = this.text;
data['externalUrl'] = this.externalUrl;
data['mixType'] = this.mixType;
if (this.pictureElem != null) {
data['pictureElem'] = this.pictureElem!.toJson();
}
if (this.soundElem != null) {
data['soundElem'] = this.soundElem!.toJson();
}
if (this.videoElem != null) {
data['videoElem'] = this.videoElem!.toJson();
}
if (this.fileElem != null) {
data['fileElem'] = this.fileElem!.toJson();
}
data['ex'] = this.ex;
return data;
}
}