diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 71fcae3..21b2095 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index 53449da..b0f6971 100644 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -1,8 +1,6 @@ - - - + diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/OnMessageKvInfoListener.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/OnMessageKvInfoListener.java deleted file mode 100644 index 5786c59..0000000 --- a/android/src/main/java/io/openim/flutter_openim_sdk/listener/OnMessageKvInfoListener.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.openim.flutter_openim_sdk.listener; - -import io.openim.flutter_openim_sdk.util.CommonUtil; - -public class OnMessageKvInfoListener implements open_im_sdk_callback.OnMessageKvInfoListener { - - // 经过聚合后的kv,计算了总数,判断了是否包含自己 - @Override - public void onMessageKvInfoChanged(String s) { - CommonUtil.emitEvent("messageKvInfoListener", "onMessageKvInfoChanged", s); - } -} diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java b/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java index ce5e4d7..cdbcc43 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java @@ -5,7 +5,6 @@ import io.flutter.plugin.common.MethodChannel; import io.openim.flutter_openim_sdk.listener.OnAdvancedMsgListener; import io.openim.flutter_openim_sdk.listener.OnBaseListener; import io.openim.flutter_openim_sdk.listener.OnCustomBusinessListener; -import io.openim.flutter_openim_sdk.listener.OnMessageKvInfoListener; import io.openim.flutter_openim_sdk.listener.OnMsgSendListener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.Open_im_sdk; @@ -14,74 +13,6 @@ import open_im_sdk.Open_im_sdk; public class MessageManager extends BaseManager { private final static String KEY_ID = "id"; - // private final static Map listeners = new HashMap<>(); - /* private static boolean initializedListener = false; - private final static Map listeners = new ConcurrentHashMap<>(); - - protected void clearListeners() { - initializedListener = false; - listeners.clear(); - } - - private final static OnAdvancedMsgListener sdkMsgListener = new OnAdvancedMsgListener() { - @Override - public void onRecvC2CReadReceipt(String s) { - for (AdvancedMsgListener l : listeners.values()) { - l.onRecvC2CReadReceipt(s); - } - } - - @Override - public void onRecvMessageRevoked(String s) { - for (AdvancedMsgListener l : listeners.values()) { - l.onRecvMessageRevoked(s); - } - } - - @Override - public void onRecvNewMessage(String s) { - for (AdvancedMsgListener l : listeners.values()) { - l.onRecvNewMessage(s); - } - } - }; - - public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { - String key = methodCall.argument(KEY_ID); - Open_im_sdk.addAdvancedMsgListener(new AdvancedMsgListener(key)); - listeners.put(key, new AdvancedMsgListener(key)); - if (!initializedListener) { - initializedListener = true; - Open_im_sdk.addAdvancedMsgListener(sdkMsgListener); - } - } - - public void removeAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { - String key = methodCall.argument(KEY_ID); - listeners.remove(key); - if (listeners.isEmpty()) { - initializedListener = false; - Open_im_sdk.removeAdvancedMsgListener(sdkMsgListener); - } - }*/ -/* - - public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { - String key = methodCall.argument(KEY_ID); - if (!listeners.containsKey(key)) { - AdvancedMsgListener listener = new AdvancedMsgListener(key); - listeners.put(methodCall.argument(KEY_ID), listener); - Open_im_sdk.addAdvancedMsgListener(listener); - } - } - - public void removeAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { - String key = methodCall.argument(KEY_ID); - OnAdvancedMsgListener listener = listeners.remove(key); - Open_im_sdk.removeAdvancedMsgListener(listener); - } - -*/ public void setAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { String key = methodCall.argument(KEY_ID); Open_im_sdk.setAdvancedMsgListener(new OnAdvancedMsgListener(key)); @@ -437,54 +368,4 @@ public class MessageManager extends BaseManager { result.success(null); } - - public void setMessageKvInfoListener(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.setMessageKvInfoListener(new OnMessageKvInfoListener()); - - result.success(null); - } - -// public void setMessageReactionExtensions(MethodCall methodCall, MethodChannel.Result result) { -// Open_im_sdk.setMessageReactionExtensions( -// new OnBaseListener(result, methodCall), -// value(methodCall, "operationID"), -// jsonValue(methodCall, "message"), -// jsonValue(methodCall, "list") -// ); -// } -// -// public void deleteMessageReactionExtensions(MethodCall methodCall, MethodChannel.Result result) { -// Open_im_sdk.deleteMessageReactionExtensions( -// new OnBaseListener(result, methodCall), -// value(methodCall, "operationID"), -// jsonValue(methodCall, "message"), -// jsonValue(methodCall, "list") -// ); -// } -// -// public void getMessageListReactionExtensions(MethodCall methodCall, MethodChannel.Result result) { -// Open_im_sdk.getMessageListReactionExtensions( -// new OnBaseListener(result, methodCall), -// value(methodCall, "operationID"), -// jsonValue(methodCall, "messageList") -// ); -// } -// -// public void addMessageReactionExtensions(MethodCall methodCall, MethodChannel.Result result) { -// Open_im_sdk.addMessageReactionExtensions( -// new OnBaseListener(result, methodCall), -// value(methodCall, "operationID"), -// jsonValue(methodCall, "message"), -// jsonValue(methodCall, "list") -// ); -// } -// -// public void getMessageListSomeReactionExtensions(MethodCall methodCall, MethodChannel.Result result) { -// Open_im_sdk.getMessageListSomeReactionExtensions( -// new OnBaseListener(result, methodCall), -// value(methodCall, "operationID"), -// jsonValue(methodCall, "messageList"), -// jsonValue(methodCall, "list") -// ); -// } } diff --git a/ios/Classes/Module/MessageManager.swift b/ios/Classes/Module/MessageManager.swift index 6044a84..6618cee 100644 --- a/ios/Classes/Module/MessageManager.swift +++ b/ios/Classes/Module/MessageManager.swift @@ -3,8 +3,7 @@ import OpenIMCore public class MessageManager: BaseServiceManager { private let KEY_ID: String = "id" - // private var listeners: [String: AdvancedMsgListener] = [:] - + public override func registerHandlers() { super.registerHandlers() self["setAdvancedMsgListener"] = setAdvancedMsgListener @@ -53,8 +52,6 @@ public class MessageManager: BaseServiceManager { self["createVideoMessageByURL"] = createVideoMessageByURL self["createFileMessageByURL"] = createFileMessageByURL self["setCustomBusinessListener"] = setCustomBusinessListener - self["setMessageKvInfoListener"] = setMessageKvInfoListener - } func setAdvancedMsgListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ @@ -249,11 +246,6 @@ public class MessageManager: BaseServiceManager { Open_im_sdkSetCustomBusinessListener(CustomBusinessListener(channel: channel)) callBack(result) } - - func setMessageKvInfoListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ - Open_im_sdkSetMessageKvInfoListener(MessageKvInfoListener(channel: channel)) - callBack(result) - } } public class SendMsgProgressListener: NSObject, Open_im_sdk_callbackSendMsgCallBackProtocol { @@ -375,18 +367,3 @@ public class CustomBusinessListener: NSObject, Open_im_sdk_callbackOnCustomBusin } } - -public class MessageKvInfoListener: NSObject, Open_im_sdk_callbackOnMessageKvInfoListenerProtocol { - - - private let channel: FlutterMethodChannel - - init(channel: FlutterMethodChannel) { - self.channel = channel - } - - public func onMessageKvInfoChanged(_ s: String?) { - CommonUtil.emitEvent(channel: channel, method: "messageKvInfoListener", type: "onMessageKvInfoChanged", errCode: nil, errMsg: nil, data: s) - } - -} diff --git a/ios/Classes/SwiftFlutterOpenimSdkPlugin.swift b/ios/Classes/SwiftFlutterOpenimSdkPlugin.swift index 7132f6f..00cc6e0 100644 --- a/ios/Classes/SwiftFlutterOpenimSdkPlugin.swift +++ b/ios/Classes/SwiftFlutterOpenimSdkPlugin.swift @@ -8,9 +8,6 @@ public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin { let messageManager: MessageManager let groupManager: GroupManager let userManger: UserManager -// let signalingManager: SignalingManager -// let workMomentsManager: WorkMomentsManager -// let organizationManager: OrganizationManager init(channel: FlutterMethodChannel) { self.imManager = IMMananger(channel: channel) @@ -19,9 +16,6 @@ public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin { self.messageManager = MessageManager(channel: channel) self.groupManager = GroupManager(channel: channel) self.userManger = UserManager(channel: channel) -// self.signalingManager = SignalingManager(channel: channel) -// self.workMomentsManager = WorkMomentsManager(channel: channel) -// self.organizationManager = OrganizationManager(channel: channel) } public static func register(with registrar: FlutterPluginRegistrar) { @@ -45,12 +39,6 @@ public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin { groupManager.handleMethod(call: call, result: result) case "userManager": userManger.handleMethod(call: call, result: result) -// case "signalingManager": -// signalingManager.handleMethod(call: call, result: result) -// case "workMomentsManager": -// workMomentsManager.handleMethod(call: call, result: result) -// case "organizationManager": -// organizationManager.handleMethod(call: call, result: result) default: print("Handle ManagerName Error: \(managerName) not found") } diff --git a/lib/flutter_openim_sdk.dart b/lib/flutter_openim_sdk.dart index cdc3bc8..dcbbc68 100644 --- a/lib/flutter_openim_sdk.dart +++ b/lib/flutter_openim_sdk.dart @@ -18,7 +18,6 @@ export 'src/listener/custom_business_listener.dart'; export 'src/listener/friendship_listener.dart'; export 'src/listener/group_listener.dart'; export 'src/listener/listener_for_service.dart'; -export 'src/listener/message_kv_info_listener.dart'; export 'src/listener/msg_send_progress_listener.dart'; export 'src/listener/upload_file_listener.dart'; export 'src/listener/user_listener.dart'; @@ -30,7 +29,6 @@ export 'src/manager/im_message_manager.dart'; export 'src/manager/im_user_manager.dart'; export 'src/models/conversation_info.dart'; export 'src/models/group_info.dart'; -export 'src/models/meeting_info.dart'; export 'src/models/message.dart'; export 'src/models/notification_info.dart'; export 'src/models/search_info.dart'; diff --git a/lib/src/enum/conversation_type.dart b/lib/src/enum/conversation_type.dart index a609639..aef93fd 100644 --- a/lib/src/enum/conversation_type.dart +++ b/lib/src/enum/conversation_type.dart @@ -1,14 +1,15 @@ -/// 会话类型 +/// Conversation types class ConversationType { - /// 单聊 + /// Single chat static const single = 1; - /// 群 + /// Group (Deprecated in v3) + @Deprecated('Use superGroup instead') static const group = 2; - /// 大群 + /// Super group chat static const superGroup = 3; - /// 通知 + /// Notification static const notification = 4; } diff --git a/lib/src/enum/group_at_type.dart b/lib/src/enum/group_at_type.dart index cafe970..95cf26e 100644 --- a/lib/src/enum/group_at_type.dart +++ b/lib/src/enum/group_at_type.dart @@ -1,17 +1,17 @@ -/// 会话强提示内容 +/// Conversation Strong Hint Content class GroupAtType { - /// 取消所有提示,即调用了resetConversationGroupAtType方法 + /// Cancel all hints, equivalent to calling the resetConversationGroupAtType method static const atNormal = 0; - /// @了我提示 + /// @ me hint static const atMe = 1; - /// @了所有人提示 + /// @ all hint static const atAll = 2; - /// @了所有人@了我 + /// @ all and @ me hint static const atAllAtMe = 3; - /// 群公告提示 + /// Group notification hint static const groupNotification = 4; } diff --git a/lib/src/enum/group_role_level.dart b/lib/src/enum/group_role_level.dart index 826d57b..417cd5c 100644 --- a/lib/src/enum/group_role_level.dart +++ b/lib/src/enum/group_role_level.dart @@ -1,11 +1,11 @@ -/// 群成员角色 +/// Group Member Roles class GroupRoleLevel { - /// 群主 + /// Group owner static const owner = 100; - /// 管理员 + /// Administrator static const admin = 60; - /// 普通成员 + /// Regular member static const member = 20; } diff --git a/lib/src/enum/group_type.dart b/lib/src/enum/group_type.dart index 434ec59..0fac836 100644 --- a/lib/src/enum/group_type.dart +++ b/lib/src/enum/group_type.dart @@ -1,8 +1,9 @@ -/// 组类型 +/// Group Types class GroupType { - /// 普通群 + /// General group (Deprecated in v3) + @Deprecated('Use work instead') static const int general = 0; - /// 工作群 + /// Work group static const int work = 2; } diff --git a/lib/src/enum/group_verification.dart b/lib/src/enum/group_verification.dart index b00e468..2bbfe5b 100644 --- a/lib/src/enum/group_verification.dart +++ b/lib/src/enum/group_verification.dart @@ -1,11 +1,11 @@ -/// 进群验证设置选项 +/// Group Join Verification Settings class GroupVerification { - /// 申请需要同意 邀请直接进 + /// Apply and invite directly for entry static const int applyNeedVerificationInviteDirectly = 0; - /// 所有人进群需要验证,除了群主管理员邀 + /// Everyone needs verification to join, except for group owners and administrators who can invite directly static const int allNeedVerification = 1; - /// 直接进群 + /// Directly join the group static const int directly = 2; } diff --git a/lib/src/enum/im_platform.dart b/lib/src/enum/im_platform.dart index 6729633..dbf9002 100644 --- a/lib/src/enum/im_platform.dart +++ b/lib/src/enum/im_platform.dart @@ -1,15 +1,16 @@ -/// 当前flutter平台仅支持Android/ios +/// The current Flutter platform supports only Android/iOS class IMPlatform { - /// IOS + /// iOS static const ios = 1; /// Android static const android = 2; + static const windows = 3; static const xos = 4; static const web = 5; - static const mini_web = 6; + static const miniWeb = 6; static const linux = 7; - static const android_pad = 8; + static const androidPad = 8; static const ipad = 9; } diff --git a/lib/src/enum/listener_type.dart b/lib/src/enum/listener_type.dart index 86c3c5f..d9c7ea7 100644 --- a/lib/src/enum/listener_type.dart +++ b/lib/src/enum/listener_type.dart @@ -1,4 +1,4 @@ -/// callback类型 +/// Callback Types class ListenerType { static const simpleMsgListener = 'simpleMsgListener'; static const connectListener = 'connectListener'; diff --git a/lib/src/enum/message_status.dart b/lib/src/enum/message_status.dart index 4d3ca8a..3fb7a0c 100644 --- a/lib/src/enum/message_status.dart +++ b/lib/src/enum/message_status.dart @@ -1,14 +1,14 @@ -/// 消息发送状态 +/// Message Send Status class MessageStatus { - /// 发送中 + /// Sending static const sending = 1; - /// 已发送成功 + /// Successfully sent static const succeeded = 2; - /// 发送失败 + /// Send failed static const failed = 3; - /// 已经删除 + /// Already deleted static const deleted = 4; } diff --git a/lib/src/enum/message_type.dart b/lib/src/enum/message_type.dart index 5d114b8..390c64c 100644 --- a/lib/src/enum/message_type.dart +++ b/lib/src/enum/message_type.dart @@ -1,171 +1,179 @@ -/// 消息类型 +/// Message Types class MessageType { - /// 普通文本 + /// Normal text static const text = 101; - /// 图片 + /// Picture static const picture = 102; - /// 语音 + /// Voice static const voice = 103; - /// 视频 + /// Video static const video = 104; - /// 文件 + /// File static const file = 105; - /// @消息 - static const at_text = 106; + /// @ Message + static const atText = 106; - /// 合并 + /// Merge static const merger = 107; - /// 名片 + /// Business Card static const card = 108; - /// 位置 + /// Location static const location = 109; - /// 自定义 + /// Custom static const custom = 110; - /// 已读回执 - static const has_read_receipt = 112; + /// Has Read Receipt + static const hasReadReceipt = 112; - /// 正字输入 + /// Typing static const typing = 113; - /// 引用回复 + /// Quote Reply static const quote = 114; - /// 自定义表情 - static const custom_face = 115; + /// Custom Emoji + static const customFace = 115; - /// 群消息已读回执 + /// Group Message Has Read Receipt (Deprecated in v3) + @Deprecated('Use GroupHasReadReceiptNotification instead') static const groupHasReadReceipt = 116; - /// 富文本消息 + /// Rich Text Message static const advancedText = 117; static const customMsgNotTriggerConversation = 119; static const customMsgOnlineOnly = 120; - /// 通知类型 + /// Notification Types static const notificationBegin = 1000; static const friendNotificationBegin = 1200; - /// 好友申请已接受 + /// Friend Request Accepted static const friendApplicationApprovedNotification = 1201; - /// 好友申请已拒绝 + /// Friend Request Rejected static const friendApplicationRejectedNotification = 1202; - /// 好友申请 + /// Friend Request static const friendApplicationNotification = 1203; - /// 好友已添加 + /// Friend Added static const friendAddedNotification = 1204; - /// 好友已删除 + /// Friend Deleted static const friendDeletedNotification = 1205; - /// 设置好友备注 + /// Set Friend Remark static const friendRemarkSetNotification = 1206; - /// 好友加入黑名单 + /// Friend Added to Blacklist static const blackAddedNotification = 1207; - /// 已从黑名单移除 + /// Removed from Blacklist static const blackDeletedNotification = 1208; static const friendNotificationEnd = 1299; - /// 会话改变 + /// Conversation Change static const conversationChangeNotification = 1300; static const userNotificationBegin = 1301; - /// 用户信息改变 + /// User Information Changed static const userInfoUpdatedNotification = 1303; static const userNotificationEnd = 1399; - /// OA通知 + /// OA Notification static const oaNotification = 1400; static const groupNotificationBegin = 1500; - /// 群已被创建 + /// Group Created static const groupCreatedNotification = 1501; - /// 群资料改变 + /// Group Info Set static const groupInfoSetNotification = 1502; - /// 进群申请 + /// Join Group Application static const joinGroupApplicationNotification = 1503; - /// 群成员退出 + /// Group Member Quit static const memberQuitNotification = 1504; - /// 群申请被接受 + /// Group Application Accepted static const groupApplicationAcceptedNotification = 1505; - /// 群申请被拒绝 + /// Group Application Rejected static const groupApplicationRejectedNotification = 1506; - /// 群拥有者权限转移 + /// Group Owner Transferred static const groupOwnerTransferredNotification = 1507; - /// 群成员被踢出群 + /// Member Kicked from Group static const memberKickedNotification = 1508; - /// 邀请进群 + /// Member Invited to Group static const memberInvitedNotification = 1509; - /// 群成员进群 + /// Member Entered Group static const memberEnterNotification = 1510; - /// 解散群 + /// Dismiss Group static const dismissGroupNotification = 1511; static const groupNotificationEnd = 1599; - /// 群成员被禁言 + /// Group Member Muted static const groupMemberMutedNotification = 1512; - /// 群成员被取消禁言 + /// Group Member Cancel Muted static const groupMemberCancelMutedNotification = 1513; - /// 群禁言 + /// Group Muted static const groupMutedNotification = 1514; - /// 取消群禁言 + /// Cancel Group Muted static const groupCancelMutedNotification = 1515; - /// 群成员信息改变 + /// Group Member Information Changed static const groupMemberInfoChangedNotification = 1516; - /// 群公告修改 - static const groupNoticeChangedNotification = 1519; - - /// 群名字修改 - static const groupNameChangedNotification = 1520; + /// Group Member Set to Admin + static const groupMemberSetToAdminNotification = 1517; - static const signalingNotificationBegin = 1600; + static const groupMemberSetToOrdinaryUserNotification = 1518; - /// 信令 - static const signalingNotification = 1601; + /// Group Notice Changed + static const groupNoticeChangedNotification = 1519; - static const signalingNotificationEnd = 1699; + /// Group Name Changed + static const groupNameChangedNotification = 1520; - /// 阅后即焚 + /// Burn After Reading static const burnAfterReadingNotification = 1701; static const notificationEnd = 2000; - /// 撤回消息 + /// Business Notification + static const businessNotification = 2001; + + /// Recall Message static const revokeMessageNotification = 2101; + + /// Single Chat Has Read Receipt + static const signalHasReadReceiptNotification = 2150; + + /// Group Chat Has Read Receipt + static const groupHasReadReceiptNotification = 2155; } diff --git a/lib/src/enum/sdk_error_code.dart b/lib/src/enum/sdk_error_code.dart index 632d1e4..bbe94b5 100644 --- a/lib/src/enum/sdk_error_code.dart +++ b/lib/src/enum/sdk_error_code.dart @@ -1,172 +1,155 @@ -// /// 消息发送失败 -// class MessageFailedCode { -// /// 被对方拉黑 -// static const int blockedByFriend = 1302; -// -// /// 被对方删除 -// static const int deletedByFriend = 1303; -// -// /// 已被移除群聊/群已解散 -// static const int notInGroup = 1204; -// } -// -// /// 添加好友失败 -// class AddFriendFailedCode { -// /// 该用户已设置不可添加 -// static const int refuseToAddFriends = 10013; -// } - +/// SDK Error Codes class SDKErrorCode { - /// 网络请求错误 + /// Network Request Error static const int networkRequestError = 10000; - /// 网络等待超时错误 + /// Network Waiting Timeout Error static const int networkWaitTimeoutError = 10001; - /// 参数错误 + /// Parameter Error static const int parameterError = 10002; - /// 上下文超时错误,通常为用户已经退出 + /// Context Timeout Error, usually when the user has already logged out static const int contextTimeoutError = 10003; - /// 资源未加载完毕,通常为未初始化,或者登录接口还未成功返回 + /// Resources not loaded completely, usually uninitialized or login hasn't completed static const int resourceNotLoaded = 10004; - /// 未知错误,需要根据 errmsg 确认原因 + /// Unknown Error, check the error message for details static const int unknownError = 10005; - /// sdk 内部错误,需要根据 errmsg 确认原因 + /// SDK Internal Error, check the error message for details static const int sdkInternalError = 10006; - /// 该用户已设置不可添加 + /// This user has set not to be added static const int refuseToAddFriends = 10013; - /// 用户不存在或未注册 + /// User does not exist or is not registered static const int userNotExistOrNotRegistered = 10100; - /// 用户已经退出登录 + /// User has already logged out static const int userHasLoggedOut = 10101; - /// 用户重复登录,可以通过 getloginstatus 确认登录状态,避免重复登录 + /// User is attempting to log in again, check the login status to avoid duplicate logins static const int repeatLogin = 10102; - /// 需要上传的文件不存在 + /// The file to upload does not exist static const int uploadFileNotExist = 10200; - /// 消息解压失败 + /// Message decompression failed static const int messageDecompressionFailed = 10201; - /// 消息解码失败 + /// Message decoding failed static const int messageDecodingFailed = 10202; - /// 不支持的长连接二进制协议 + /// Unsupported long connection binary protocol static const int unsupportedLongConnection = 10203; - /// 消息重复发送 + /// Message sent multiple times static const int messageRepeated = 10204; - /// 消息内容类型不支持 + /// Message content type not supported static const int messageContentTypeNotSupported = 10205; - /// 不支持的会话操作 + /// Unsupported session operation static const int unsupportedSessionOperation = 10301; - /// 群 ID 不存在 + /// Group ID does not exist static const int groupIDNotExist = 10400; - /// 群组类型错误 + /// Group type is incorrect static const int wrongGroupType = 10401; - /// 服务器内部错误,通常为内部网络错误,需要检查服务器各节点运行是否正常 + /// Server Internal Error, usually an internal network error, check if server nodes are running correctly static const int serverInternalError = 500; - /// 参数错误,需要检查 body 参数以及 header 参数是否正确 + /// Parameter Error on the server, check if body and header parameters are correct static const int serverParameterError = 1001; - /// 权限不足,一般为 header 参数中携带 token 不正确,或者权限越级操作 + /// Insufficient Permissions, typically when the token in the header is incorrect or when trying to perform unauthorized actions static const int insufficientPermissions = 1002; - /// 数据库主键重复 + /// Duplicate Database Primary Key static const int duplicateDatabasePrimaryKey = 1003; - /// 数据库记录未找到 + /// Database Record Not Found static const int databaseRecordNotFound = 1004; - /// 用户 ID 不存在 + /// User ID does not exist static const int userIDNotExist = 1101; - /// 用户已经注册 + /// User is already registered static const int userAlreadyRegistered = 1102; - /// 群不存在 + /// Group does not exist static const int groupNotExis = 1201; - /// 群已存在 + /// Group already exists static const int groupAlreadyExists = 1202; - /// 用户不在群组中 + /// User is not in the group static const int userIsNotInGroup = 1203; - /// 群组已解散 + /// Group has been disbanded static const int groupDisbanded = 1204; - /// 群申请已经被处理,不需要重复处理 + /// Group application has already been processed, no need to process it again static const int groupApplicationHasBeenProcessed = 1206; - /// 不能添加自己为好友 + /// Cannot add yourself as a friend static const int notAddMyselfAsAFriend = 1301; - /// 已被对方拉黑 + /// You have been blocked by the other party static const int hasBeenBlocked = 1302; - /// 对方不是自己的好友 + /// The other party is not your friend static const int notFriend = 1303; - /// 已经是好友关系,不需要重复申请 + /// Already in a friend relationship, no need to reapply static const int alreadyAFriendRelationship = 1304; - /// 消息已读功能被关闭 + /// Message read function is turned off static const int messageReadFunctionIsTurnedOff = 1401; - /// 你已被禁言,不能在群里发言 + /// You have been banned from speaking in the group static const int youHaveBeenBanned = 1402; - /// 群已被禁言,不能发言 + /// The group has been banned from posting static const int groupHasBeenBanned = 1403; - /// 该消息已被撤回 + /// This message has been retracted static const int messageHasBeenRetracted = 1404; - /// 授权过期 + /// Authorization has expired static const int licenseExpired = 1405; - /// token 已经过期 + /// Token has expired static const int tokenHasExpired = 1501; - /// token 无效 + /// Invalid token static const int tokenInvalid = 1502; - /// token 格式错误 + /// Token format error static const int tokenFormatError = 1503; - /// token 还未生效 + /// Token has not yet taken effect static const int tokenHasNotYetTakenEffect = 1504; - /// 未知 token 错误 + /// Unknown token error static const int unknownTokenError = 1505; - /// 被踢出的 token,无效 + /// The kicked-out token is invalid static const int thekickedOutTokenIsInvalid = 1506; - /// token 不存在 + /// Token does not exist static const int tokenNotExist = 1507; - /// 连接数超过网关最大限制 + /// Number of Connections Exceeds Gateway's Maximum Limit static const int connectionsExceedsMaximumLimit = 1601; - /// 连接握手参数错误 + /// Handshake Parameter Error static const int handshakeParameterError = 1602; - /// 文件上传过期 + /// File Upload Expired static const int fileUploadExpired = 1701; } diff --git a/lib/src/listener/advanced_msg_listener.dart b/lib/src/listener/advanced_msg_listener.dart index 47444c2..0d29b41 100644 --- a/lib/src/listener/advanced_msg_listener.dart +++ b/lib/src/listener/advanced_msg_listener.dart @@ -1,13 +1,11 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; -/// 消息监听 +/// Message Listener class OnAdvancedMsgListener { Function(Message msg)? onMsgDeleted; Function(RevokedInfo info)? onNewRecvMessageRevoked; Function(List list)? onRecvC2CReadReceipt; Function(List list)? onRecvGroupReadReceipt; - Function(String msgID, List list)? onRecvMessageExtensionsAdded; - Function(String msgID, List list)? onRecvMessageExtensionsChanged; Function(String msgID, List list)? onRecvMessageExtensionsDeleted; Function(Message msg)? onRecvNewMessage; Function(Message msg)? onRecvOfflineNewMessage; @@ -20,8 +18,6 @@ class OnAdvancedMsgListener { this.onNewRecvMessageRevoked, this.onRecvC2CReadReceipt, this.onRecvGroupReadReceipt, - this.onRecvMessageExtensionsAdded, - this.onRecvMessageExtensionsChanged, this.onRecvMessageExtensionsDeleted, this.onRecvNewMessage, this.onRecvOfflineNewMessage, @@ -31,38 +27,28 @@ class OnAdvancedMsgListener { onMsgDeleted?.call(msg); } - /// 消息被撤回 + /// Message has been retracted void newRecvMessageRevoked(RevokedInfo info) { onNewRecvMessageRevoked?.call(info); } - /// C2C消息已读回执 + /// C2C Message Read Receipt void recvC2CReadReceipt(List list) { onRecvC2CReadReceipt?.call(list); } - /// 群消息已读回执 + /// Group Message Read Receipt void recvGroupReadReceipt(List list) { onRecvGroupReadReceipt?.call(list); } - /// 收到拓展消息kv新增 - void recvMessageExtensionsAdded(String msgID, List list) { - onRecvMessageExtensionsAdded?.call(msgID, list); - } - - /// 收到拓展消息kv改变 - void recvMessageExtensionsChanged(String msgID, List list) { - onRecvMessageExtensionsChanged?.call(msgID, list); - } - - /// 收到扩展消息被删除 - /// [list] 被删除的TypeKey + /// Received Extended Message Deleted + /// [list] TypeKey that was deleted void recvMessageExtensionsDeleted(String msgID, List list) { onRecvMessageExtensionsDeleted?.call(msgID, list); } - /// 收到了一条新消息 + /// Received a new message void recvNewMessage(Message msg) { onRecvNewMessage?.call(msg); } diff --git a/lib/src/listener/connect_listener.dart b/lib/src/listener/connect_listener.dart index a354717..baad63a 100644 --- a/lib/src/listener/connect_listener.dart +++ b/lib/src/listener/connect_listener.dart @@ -1,4 +1,4 @@ -/// SDK 连接状态监听 +/// SDK Connection State Listener class OnConnectListener { Function(int? code, String? errorMsg)? onConnectFailed; Function()? onConnectSuccess; @@ -14,27 +14,27 @@ class OnConnectListener { this.onUserTokenExpired, }); - /// SDK连接服务器失败 + /// SDK failed to connect to the server void connectFailed(int? code, String? errorMsg) { onConnectFailed?.call(code, errorMsg); } - /// SDK连接服务器成功 + /// SDK successfully connected to the server void connectSuccess() { onConnectSuccess?.call(); } - /// SDK正在连接服务器 + /// SDK is currently connecting to the server void connecting() { onConnecting?.call(); } - /// 账号已在其他地方登录,当前设备被踢下线 + /// The account has been logged in from another location, and the current device has been kicked offline void kickedOffline() { onKickedOffline?.call(); } - /// 登录凭证过期,需要重新登录 + /// Login credentials have expired and require reauthentication void userTokenExpired() { onUserTokenExpired?.call(); } diff --git a/lib/src/listener/conversation_listener.dart b/lib/src/listener/conversation_listener.dart index 12e8a05..2db54c8 100644 --- a/lib/src/listener/conversation_listener.dart +++ b/lib/src/listener/conversation_listener.dart @@ -1,6 +1,6 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; -/// 会话监听 +/// Conversation Listener class OnConversationListener { Function(List list)? onConversationChanged; Function(List list)? onNewConversation; @@ -18,19 +18,19 @@ class OnConversationListener { this.onSyncServerStart, }); - /// 会话发生改变 + /// Conversations have changed void conversationChanged(List list) { onConversationChanged?.call(list); } - /// 有新会话产生 + /// New conversations have been created void newConversation(List list) { onNewConversation?.call(list); } - /// 未读消息总数发送改变 - void totalUnreadMessageCountChanged(int i) { - onTotalUnreadMessageCountChanged?.call(i); + /// Total unread message count has changed + void totalUnreadMessageCountChanged(int count) { + onTotalUnreadMessageCountChanged?.call(count); } void syncServerFailed() { diff --git a/lib/src/listener/friendship_listener.dart b/lib/src/listener/friendship_listener.dart index d3ea4d7..a8e6ef5 100644 --- a/lib/src/listener/friendship_listener.dart +++ b/lib/src/listener/friendship_listener.dart @@ -1,16 +1,16 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; -/// 好友关系监听 +/// Friendship Listener class OnFriendshipListener { - Function(BlacklistInfo i)? onBlackAdded; - Function(BlacklistInfo i)? onBlackDeleted; - Function(FriendInfo i)? onFriendAdded; - Function(FriendApplicationInfo i)? onFriendApplicationAccepted; - Function(FriendApplicationInfo i)? onFriendApplicationAdded; - Function(FriendApplicationInfo i)? onFriendApplicationDeleted; - Function(FriendApplicationInfo i)? onFriendApplicationRejected; - Function(FriendInfo i)? onFriendDeleted; - Function(FriendInfo i)? onFriendInfoChanged; + Function(BlacklistInfo info)? onBlackAdded; + Function(BlacklistInfo info)? onBlackDeleted; + Function(FriendInfo info)? onFriendAdded; + Function(FriendApplicationInfo info)? onFriendApplicationAccepted; + Function(FriendApplicationInfo info)? onFriendApplicationAdded; + Function(FriendApplicationInfo info)? onFriendApplicationDeleted; + Function(FriendApplicationInfo info)? onFriendApplicationRejected; + Function(FriendInfo info)? onFriendDeleted; + Function(FriendInfo info)? onFriendInfoChanged; OnFriendshipListener({ this.onBlackAdded, @@ -24,48 +24,48 @@ class OnFriendshipListener { this.onFriendInfoChanged, }); - /// 已被加入黑名单 - void blackAdded(BlacklistInfo u) { - onBlackAdded?.call(u); + /// Added to the blacklist + void blackAdded(BlacklistInfo info) { + onBlackAdded?.call(info); } - /// 已从黑名单移除 - void blackDeleted(BlacklistInfo u) { - onBlackDeleted?.call(u); + /// Removed from the blacklist + void blackDeleted(BlacklistInfo info) { + onBlackDeleted?.call(info); } - /// 好友已添加 - void friendAdded(FriendInfo u) { - onFriendAdded?.call(u); + /// Friend added + void friendAdded(FriendInfo info) { + onFriendAdded?.call(info); } - /// 好友申请已被接受 - void friendApplicationAccepted(FriendApplicationInfo u) { - onFriendApplicationAccepted?.call(u); + /// Friend application accepted + void friendApplicationAccepted(FriendApplicationInfo info) { + onFriendApplicationAccepted?.call(info); } - /// 已添加新的好友申请 - void friendApplicationAdded(FriendApplicationInfo u) { - onFriendApplicationAdded?.call(u); + /// New friend application added + void friendApplicationAdded(FriendApplicationInfo info) { + onFriendApplicationAdded?.call(info); } - /// 好友申请已被删除 - void friendApplicationDeleted(FriendApplicationInfo u) { - onFriendApplicationDeleted?.call(u); + /// Friend application deleted + void friendApplicationDeleted(FriendApplicationInfo info) { + onFriendApplicationDeleted?.call(info); } - /// 好友申请已被拒绝 - void friendApplicationRejected(FriendApplicationInfo u) { - onFriendApplicationRejected?.call(u); + /// Friend application rejected + void friendApplicationRejected(FriendApplicationInfo info) { + onFriendApplicationRejected?.call(info); } - /// 好友已被删除 - void friendDeleted(FriendInfo u) { - onFriendDeleted?.call(u); + /// Friend deleted + void friendDeleted(FriendInfo info) { + onFriendDeleted?.call(info); } - /// 好友资料发生改变 - void friendInfoChanged(FriendInfo u) { - onFriendInfoChanged?.call(u); + /// Friend information changed + void friendInfoChanged(FriendInfo info) { + onFriendInfoChanged?.call(info); } } diff --git a/lib/src/listener/group_listener.dart b/lib/src/listener/group_listener.dart index df250d4..8091dfb 100644 --- a/lib/src/listener/group_listener.dart +++ b/lib/src/listener/group_listener.dart @@ -1,6 +1,6 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; -/// 群组监听 +/// Group Listener class OnGroupListener { Function(GroupApplicationInfo info)? onGroupApplicationAccepted; Function(GroupApplicationInfo info)? onGroupApplicationAdded; @@ -28,22 +28,22 @@ class OnGroupListener { this.onJoinedGroupDeleted, }); - /// 群申请已被接受 + /// Group application accepted void groupApplicationAccepted(GroupApplicationInfo info) { onGroupApplicationAccepted?.call(info); } - /// 群申请已被添加 + /// Group application added void groupApplicationAdded(GroupApplicationInfo info) { onGroupApplicationAdded?.call(info); } - /// 群申请已被删除 + /// Group application deleted void groupApplicationDeleted(GroupApplicationInfo info) { onGroupApplicationDeleted?.call(info); } - /// 群申请已被拒绝 + /// Group application rejected void groupApplicationRejected(GroupApplicationInfo info) { onGroupApplicationRejected?.call(info); } @@ -52,32 +52,32 @@ class OnGroupListener { onGroupDismissed?.call(info); } - /// 群资料发生改变 + /// Group information changed void groupInfoChanged(GroupInfo info) { onGroupInfoChanged?.call(info); } - /// 群成员已添加 + /// Group member added void groupMemberAdded(GroupMembersInfo info) { onGroupMemberAdded?.call(info); } - /// 群成员已删除 + /// Group member deleted void groupMemberDeleted(GroupMembersInfo info) { onGroupMemberDeleted?.call(info); } - /// 群成员信息发送改变 + /// Group member information changed void groupMemberInfoChanged(GroupMembersInfo info) { onGroupMemberInfoChanged?.call(info); } - /// 已加入的群有新增 + /// Joined group added void joinedGroupAdded(GroupInfo info) { onJoinedGroupAdded?.call(info); } - /// 已加入的群减少 + /// Joined group deleted void joinedGroupDeleted(GroupInfo info) { onJoinedGroupDeleted?.call(info); } diff --git a/lib/src/listener/listener_for_service.dart b/lib/src/listener/listener_for_service.dart index 3102af0..35da7a1 100644 --- a/lib/src/listener/listener_for_service.dart +++ b/lib/src/listener/listener_for_service.dart @@ -1,6 +1,6 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; -/// 好友关系监听 +/// Friend Relationship Listener class OnListenerForService { Function(FriendApplicationInfo i)? onFriendApplicationAdded; Function(FriendApplicationInfo i)? onFriendApplicationAccepted; diff --git a/lib/src/listener/message_kv_info_listener.dart b/lib/src/listener/message_kv_info_listener.dart deleted file mode 100644 index 275c2ad..0000000 --- a/lib/src/listener/message_kv_info_listener.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; - -class OnMessageKvInfoListener { - Function(List list)? onMessageKvInfoChanged; - - OnMessageKvInfoListener({this.onMessageKvInfoChanged}); - - void messageKvInfoChanged(List list) { - onMessageKvInfoChanged?.call(list); - } -} diff --git a/lib/src/listener/msg_send_progress_listener.dart b/lib/src/listener/msg_send_progress_listener.dart index 9163690..4baf175 100644 --- a/lib/src/listener/msg_send_progress_listener.dart +++ b/lib/src/listener/msg_send_progress_listener.dart @@ -1,10 +1,10 @@ -/// 消息发送进度监听 +/// Message Sending Progress Listener class OnMsgSendProgressListener { Function(String clientMsgID, int progress)? onProgress; OnMsgSendProgressListener({this.onProgress}); - /// 消息发送进度 + /// Message sending progress void progress(String clientMsgID, int progress) { onProgress?.call(clientMsgID, progress); } diff --git a/lib/src/listener/user_listener.dart b/lib/src/listener/user_listener.dart index a97255a..3eb3b73 100644 --- a/lib/src/listener/user_listener.dart +++ b/lib/src/listener/user_listener.dart @@ -1,6 +1,6 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; -/// 当前用户资料监听 +/// Current User Profile Listener class OnUserListener { /// The information of the logged-in user has been updated Function(UserInfo info)? onSelfInfoUpdated; @@ -8,11 +8,12 @@ class OnUserListener { OnUserListener({this.onSelfInfoUpdated, this.onUserStatusChanged}); - /// 自身信息发送变化回调 + /// Callback for changes in user's own information void selfInfoUpdated(UserInfo info) { onSelfInfoUpdated?.call(info); } + /// Callback for changes in user status void userStatusChanged(UserStatusInfo info) { onUserStatusChanged?.call(info); } diff --git a/lib/src/manager/im_conversation_manager.dart b/lib/src/manager/im_conversation_manager.dart index 37d3265..d5a507c 100644 --- a/lib/src/manager/im_conversation_manager.dart +++ b/lib/src/manager/im_conversation_manager.dart @@ -9,13 +9,13 @@ class ConversationManager { ConversationManager(this._channel); - /// 会话监听 + /// Conversation Listener Future setConversationListener(OnConversationListener listener) { this.listener = listener; return _channel.invokeMethod('setConversationListener', _buildParam({})); } - /// 获取所有会话 + /// Get All Conversations Future> getAllConversationList( {String? operationID}) => _channel @@ -27,9 +27,9 @@ class ConversationManager { .then((value) => Utils.toList(value, (map) => ConversationInfo.fromJson(map))); - /// 分页获取会话 - /// [offset] 开始下标 - /// [count] 每页数量 + /// Paginate Through Conversations + /// [offset] Starting index + /// [count] Number of items per page Future> getConversationListSplit({ int offset = 0, int count = 20, @@ -46,9 +46,9 @@ class ConversationManager { .then((value) => Utils.toList(value, (map) => ConversationInfo.fromJson(map))); - /// 查询会话,如果会话不存在会自动生成一个 - /// [sourceID] 如果是单聊会话传userID,如果是群聊会话传GroupID - /// [sessionType] 参考[ConversationType] + /// Query a Conversation; if it doesn't exist, it will be created + /// [sourceID] UserID for one-on-one conversation, GroupID for group conversation + /// [sessionType] Reference [ConversationType] Future getOneConversation({ required String sourceID, required int sessionType, @@ -65,8 +65,8 @@ class ConversationManager { .then((value) => Utils.toObj(value, (map) => ConversationInfo.fromJson(map))); - /// 根据会话id获取多个会话 - /// [conversationIDList] 会话id列表 + /// Get Multiple Conversations by Conversation ID + /// [conversationIDList] List of conversation IDs Future> getMultipleConversation({ required List conversationIDList, String? operationID, @@ -81,9 +81,9 @@ class ConversationManager { .then((value) => Utils.toList(value, (map) => ConversationInfo.fromJson(map))); - /// 设置会话草稿 - /// [conversationID] 会话id - /// [draftText] 草稿 + /// Set Conversation Draft + /// [conversationID] Conversation ID + /// [draftText] Draft text Future setConversationDraft({ required String conversationID, required String draftText, @@ -97,9 +97,9 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 置顶会话 - /// [conversationID] 会话id - /// [isPinned] true:置顶,false:取消置顶 + /// Pin a Conversation + /// [conversationID] Conversation ID + /// [isPinned] true: pin, false: unpin Future pinConversation({ required String conversationID, required bool isPinned, @@ -113,8 +113,8 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 置顶会话 - /// [conversationID] 会话id + /// Hide a Conversation + /// [conversationID] Conversation ID Future hideConversation({ required String conversationID, String? operationID, @@ -126,34 +126,31 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 获取未读消息总数 - /// int.tryParse(count) ?? 0; - Future getTotalUnreadMsgCount({ - String? operationID, - }) => + /// Get Total Unread Message Count + Future getTotalUnreadMsgCount({String? operationID}) => _channel.invokeMethod( 'getTotalUnreadMsgCount', _buildParam({ "operationID": Utils.checkOperationID(operationID), })); - /// 查询会话id - /// [sourceID] 如果是单聊值传用户ID,如果是群聊值传组ID - /// [sessionType] 参考[ConversationType] - // Future getConversationIDBySessionType({ - // required String sourceID, - // required int sessionType, - // }) => - // _channel.invokeMethod( - // 'getConversationIDBySessionType', - // _buildParam({ - // "sourceID": sourceID, - // "sessionType": sessionType, - // })); + /// Query Conversation ID + /// [sourceID] UserID for one-on-one, GroupID for group + /// [sessionType] Reference [ConversationType] + Future getConversationIDBySessionType({ + required String sourceID, + required int sessionType, + }) => + _channel.invokeMethod( + 'getConversationIDBySessionType', + _buildParam({ + "sourceID": sourceID, + "sessionType": sessionType, + })); - /// 消息免打扰设置 - /// [conversationID] 会话id - /// [status] 0:正常;1:不接受消息;2:接受在线消息不接受离线消息; + /// Message Do-Not-Disturb Setting + /// [conversationID] Conversation ID + /// [status] 0: normal; 1: not receiving messages; 2: receive online messages but not offline messages Future setConversationRecvMessageOpt({ required String conversationID, required int status, @@ -167,9 +164,9 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 查询免打扰状态 - /// [conversationIDList] 会话id列表 - /// 返回:[{"conversationId":"single_13922222222","result":0}],result值:0:正常;1:不接受消息;2:接受在线消息不接受离线消息; + /// Query Do-Not-Disturb Status + /// [conversationIDList] List of conversation IDs + /// Returns: [{"conversationId":"single_13922222222","result":0}], result values: 0: normal; 1: not receiving messages; 2: receive online messages but not offline messages Future> getConversationRecvMessageOpt({ required List conversationIDList, String? operationID, @@ -183,9 +180,9 @@ class ConversationManager { })) .then((value) => Utils.toListMap(value)); - /// 阅后即焚 - /// [conversationID] 会话id - /// [isPrivate] true:开启,false:关闭 + /// Self-Destruct Messages + /// [conversationID] Conversation ID + /// [isPrivate] true: enable, false: disable Future setConversationPrivateChat({ required String conversationID, required bool isPrivate, @@ -199,8 +196,8 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 删除本地以及服务器的会话 - /// [conversationID] 会话ID + /// Delete a Conversation Locally and from the Server + /// [conversationID] Conversation ID Future deleteConversationAndDeleteAllMsg({ required String conversationID, String? operationID, @@ -212,8 +209,8 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 清空会话里的消息 - /// [conversationID] 会话ID + /// Clear Messages in a Conversation + /// [conversationID] Conversation ID Future clearConversationAndDeleteAllMsg({ required String conversationID, String? operationID, @@ -225,7 +222,7 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 删除所有本地会话 + /// Delete All Local Conversations Future deleteAllConversationFromLocal({ String? operationID, }) => @@ -235,8 +232,8 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 重置强提醒标识[GroupAtType] - /// [conversationID] 会话id + /// Reset Mentioned (Group At) Flags [GroupAtType] + /// [conversationID] Conversation ID Future resetConversationGroupAtType({ required String conversationID, String? operationID, @@ -248,7 +245,7 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 查询@所有人标识 + /// Query @ All Flag Future getAtAllTag({ String? operationID, }) => @@ -258,11 +255,11 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 查询@所有人标识 + /// Get @ All Tag String get atAllTag => 'AtAllTag'; - /// 全局免打扰 - /// [status] 0:正常;1:不接受消息;2:接受在线消息不接受离线消息; + /// Global Do-Not-Disturb + /// [status] 0: normal; 1: not receiving messages; 2: receive online messages but not offline messages Future setGlobalRecvMessageOpt({ required int status, String? operationID, @@ -274,9 +271,9 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 设置阅后即焚时长 - /// [conversationID] 会话id - /// [burnDuration] 时长s,默认30s + /// Set Self-Destruct Message Duration + /// [conversationID] Conversation ID + /// [burnDuration] Duration in seconds, default: 30s Future setConversationBurnDuration({ required String conversationID, int burnDuration = 30, @@ -290,9 +287,8 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 标记消息已读 - /// [conversationID] 会话ID - /// [messageIDList] 被标记的消息clientMsgID + /// Mark Messages as Read + /// [conversationID] Conversation ID Future markConversationMessageAsRead({ required String conversationID, String? operationID, @@ -304,8 +300,8 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 开启定期删除 - /// [isMsgDestruct] true 开启 + /// Enable Regular Deletion + /// [isMsgDestruct] true: enable Future setConversationIsMsgDestruct({ required String conversationID, bool isMsgDestruct = true, @@ -319,8 +315,8 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 定期删除聊天记录 - /// [duration] 秒 + /// Regularly Delete Chat Records + /// [duration] Seconds Future setConversationMsgDestructTime({ required String conversationID, int duration = 1 * 24 * 60 * 60, @@ -334,7 +330,7 @@ class ConversationManager { "operationID": Utils.checkOperationID(operationID), })); - /// 会话列表自定义排序规则。 + /// Custom Sort for Conversation List List simpleSort(List list) => list ..sort((a, b) { if ((a.isPinned == true && b.isPinned == true) || diff --git a/lib/src/manager/im_friendship_manager.dart b/lib/src/manager/im_friendship_manager.dart index fa76bb8..e54a8f5 100644 --- a/lib/src/manager/im_friendship_manager.dart +++ b/lib/src/manager/im_friendship_manager.dart @@ -7,14 +7,14 @@ class FriendshipManager { FriendshipManager(this._channel); - /// 好友关系监听 + /// Friend Relationship Listener Future setFriendshipListener(OnFriendshipListener listener) { this.listener = listener; return _channel.invokeMethod('setFriendListener', _buildParam({})); } - /// 查询好友信息 - /// [userIDList] userID集合 + /// Query Friend Information + /// [userIDList] List of user IDs Future> getFriendsInfo({ required List userIDList, String? operationID, @@ -28,9 +28,9 @@ class FriendshipManager { })) .then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v))); - /// 发送一个好友请求,需要对方调用同意申请才能成为好友。 - /// [userID] 被邀请的用户ID - /// [reason] 备注说明 + /// Send a Friend Request, the other party needs to accept the request to become friends. + /// [userID] User ID to be invited + /// [reason] Remark description Future addFriend({ required String userID, String? reason, @@ -44,7 +44,7 @@ class FriendshipManager { "operationID": Utils.checkOperationID(operationID), })); - /// 获取别人加我为好友的申请 + /// Get Friend Requests Sent to Me Future> getFriendApplicationListAsRecipient( {String? operationID}) => _channel @@ -56,7 +56,7 @@ class FriendshipManager { .then((value) => Utils.toList(value, (v) => FriendApplicationInfo.fromJson(v))); - /// 获取我发出的好友申请 + /// Get Friend Requests Sent by Me Future> getFriendApplicationListAsApplicant( {String? operationID}) => _channel @@ -68,7 +68,7 @@ class FriendshipManager { .then((value) => Utils.toList(value, (v) => FriendApplicationInfo.fromJson(v))); - /// 获取好友列表,返回的列表包含了已拉入黑名单的好友 + /// Get Friend List, including friends who have been put into the blacklist Future> getFriendList({String? operationID}) => _channel .invokeMethod( 'getFriendList', @@ -77,7 +77,7 @@ class FriendshipManager { })) .then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v))); - /// 获取好友列表,返回的列表包含了已拉入黑名单的好友 + /// Get Friend List, including friends who have been put into the blacklist (returns a map) Future> getFriendListMap({String? operationID}) => _channel .invokeMethod( 'getFriendList', @@ -86,9 +86,9 @@ class FriendshipManager { })) .then((value) => Utils.toListMap(value)); - /// 设置好友备注 - /// [userID] 好友的userID - /// [remark] 好友的备注 + /// Set Friend's Remark + /// [userID] Friend's userID + /// [remark] Friend's remark Future setFriendRemark({ required String userID, required String remark, @@ -102,8 +102,8 @@ class FriendshipManager { "operationID": Utils.checkOperationID(operationID), })); - /// 加入黑名单 - /// [userID] 被加入黑名单的好友ID + /// Add to Blacklist + /// [userID] Friend's ID to be added to the blacklist Future addBlacklist({ required String userID, String? operationID, @@ -115,7 +115,7 @@ class FriendshipManager { "operationID": Utils.checkOperationID(operationID), })); - /// 获取黑名单列表 + /// Get Blacklist Future> getBlacklist({String? operationID}) => _channel .invokeMethod( 'getBlacklist', @@ -124,8 +124,8 @@ class FriendshipManager { })) .then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v))); - /// 从黑名单移除 - /// [userID] 用户ID + /// Remove from Blacklist + /// [userID] User ID Future removeBlacklist({ required String userID, String? operationID, @@ -137,8 +137,8 @@ class FriendshipManager { "operationID": Utils.checkOperationID(operationID), })); - /// 检查友好关系 - /// [userIDList] userID列表 + /// Check Friendship Status + /// [userIDList] List of user IDs Future> checkFriend({ required List userIDList, String? operationID, @@ -153,8 +153,8 @@ class FriendshipManager { .then((value) => Utils.toList(value, (v) => FriendshipInfo.fromJson(v))); - /// 删除好友 - /// [userID] 用户ID + /// Delete Friend + /// [userID] User ID Future deleteFriend({ required String userID, String? operationID, @@ -166,9 +166,9 @@ class FriendshipManager { "operationID": Utils.checkOperationID(operationID), })); - /// 接受好友请求 - /// [userID] 用户ID - /// [handleMsg]备注说明 + /// Accept Friend Request + /// [userID] User ID + /// [handleMsg] Remark description Future acceptFriendApplication({ required String userID, String? handleMsg, @@ -182,9 +182,9 @@ class FriendshipManager { "operationID": Utils.checkOperationID(operationID), })); - /// 拒绝好友请求 - /// [userID] 用户ID - /// [handleMsg]备注说明 + /// Reject Friend Request + /// [userID] User ID + /// [handleMsg] Remark description Future refuseFriendApplication({ required String userID, String? handleMsg, @@ -198,11 +198,11 @@ class FriendshipManager { "operationID": Utils.checkOperationID(operationID), })); - /// 查好友 - /// [keywordList] 搜索关键词,目前仅支持一个关键词搜索,不能为空 - /// [isSearchUserID] 是否以关键词搜索好友ID(注:不可以同时为false),为空默认false - /// [isSearchNickname] 是否以关键词搜索昵称,为空默认false - /// [isSearchRemark] 是否以关键词搜索备注名,为空默认false + /// Search for Friends + /// [keywordList] Search keywords, currently supports only one keyword search, cannot be empty + /// [isSearchUserID] Whether to search for friend IDs with keywords (note: cannot be false at the same time), defaults to false if empty + /// [isSearchNickname] Whether to search by nickname with keywords, defaults to false if empty + /// [isSearchRemark] Whether to search by remark name with keywords, defaults to false if empty Future> searchFriends({ List keywordList = const [], bool isSearchUserID = false, diff --git a/lib/src/manager/im_group_manager.dart b/lib/src/manager/im_group_manager.dart index 40688df..d503c2a 100644 --- a/lib/src/manager/im_group_manager.dart +++ b/lib/src/manager/im_group_manager.dart @@ -9,15 +9,15 @@ class GroupManager { GroupManager(this._channel); - /// 组关系监听 + /// Group relationship listener Future setGroupListener(OnGroupListener listener) { this.listener = listener; return _channel.invokeMethod('setGroupListener', _buildParam({})); } - /// 邀请进组,直接进组无需同意。 - /// [groupID] 组ID - /// [userIDList] 用户ID列表 + /// Invite users to a group, allowing them to join without approval. + /// [groupID] Group ID + /// [userIDList] List of user IDs Future> inviteUserToGroup({ required String groupID, required List userIDList, @@ -33,13 +33,12 @@ class GroupManager { 'reason': reason, "operationID": Utils.checkOperationID(operationID), })) - .then((value) => - Utils.toList(value, (map) => GroupInviteResult.fromJson(map))); + .then((value) => Utils.toList(value, (map) => GroupInviteResult.fromJson(map))); - /// 移除组成员 - /// [groupID] 组ID - /// [userIDList] 用户ID列表 - /// [reason] 备注说明 + /// Remove group members + /// [groupID] Group ID + /// [userIDList] List of user IDs + /// [reason] Reason for removal Future> kickGroupMember({ required String groupID, required List userIDList, @@ -55,12 +54,11 @@ class GroupManager { 'reason': reason, "operationID": Utils.checkOperationID(operationID), })) - .then((value) => - Utils.toList(value, (map) => GroupInviteResult.fromJson(map))); + .then((value) => Utils.toList(value, (map) => GroupInviteResult.fromJson(map))); - /// 查询组成员资料 - /// [groupID] 组ID - /// [userIDList] 用户ID列表 + /// Query group member information + /// [groupID] Group ID + /// [userIDList] List of user IDs Future> getGroupMembersInfo({ required String groupID, required List userIDList, @@ -74,14 +72,13 @@ class GroupManager { 'userIDList': userIDList, "operationID": Utils.checkOperationID(operationID), })) - .then((value) => - Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); - - /// 分页获取组成员列表 - /// [groupID] 群ID - /// [filter] 过滤成员 0所有,1群主 , 2管理员,3普通成员,4管理员+普通成员 5,群主+管理员 - /// [offset] 开始下标 - /// [count] 总数 + .then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); + + /// Paginate and retrieve the group member list + /// [groupID] Group ID + /// [filter] Member filter (0: All, 1: Group owner, 2: Administrator, 3: Regular member, 4: Admin + Regular member, 5: Group owner + Admin) + /// [offset] Starting index + /// [count] Total count Future> getGroupMemberList({ required String groupID, int filter = 0, @@ -99,14 +96,13 @@ class GroupManager { 'count': count, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => - Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); - - /// 分页获取组成员列表 - /// [groupID] 群ID - /// [filter] 过滤成员 0所有,1群主 , 2管理员,3普通成员,4管理员+普通成员 5,群主+管理员 - /// [offset] 开始下标 - /// [count] 总数 + .then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); + + /// Paginate and retrieve the group member list as a map + /// [groupID] Group ID + /// [filter] Member filter (0: All, 1: Group owner, 2: Administrator, 3: Regular member, 4: Admin + Regular member, 5: Group owner + Admin) + /// [offset] Starting index + /// [count] Total count Future> getGroupMemberListMap({ required String groupID, int filter = 0, @@ -126,7 +122,7 @@ class GroupManager { })) .then((value) => Utils.toListMap(value)); - /// 查询已加入的组列表 + /// Query the list of joined groups Future> getJoinedGroupList({String? operationID}) => _channel .invokeMethod( 'getJoinedGroupList', @@ -135,7 +131,7 @@ class GroupManager { })) .then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map))); - /// 查询已加入的组列表 + /// Query the list of joined groups Future> getJoinedGroupListMap({String? operationID}) => _channel .invokeMethod( 'getJoinedGroupList', @@ -144,8 +140,8 @@ class GroupManager { })) .then((value) => Utils.toListMap(value)); - /// 检查是否已加入组 - /// [groupID] 组ID + /// Check if the user has joined a group + /// [groupID] Group ID Future isJoinedGroup({ required String groupID, String? operationID, @@ -159,14 +155,11 @@ class GroupManager { })) .then((value) => value == 'true' ? true : false); - /// 创建一个组 - /// [groupName] 群名 - /// [notification] 公告 - /// [introduction] 群介绍 - /// [faceUrl] 群头像 - /// [groupType] 组类型 [GroupType] - /// [ex] 额外信息 - /// [list] 初创群成员以及其角色列表[GroupMemberRole] + /// Create a new group + /// [groupInfo] Group information + /// [memberUserIDs] List of user IDs to add as initial members + /// [adminUserIDs] List of user IDs to add as administrators + /// [ownerUserID] User ID of the owner Future createGroup({ required GroupInfo groupInfo, List memberUserIDs = const [], @@ -184,16 +177,9 @@ class GroupManager { 'ownerUserID': ownerUserID, 'operationID': Utils.checkOperationID(operationID), })) - .then( - (value) => Utils.toObj(value, (map) => GroupInfo.fromJson(map))); - - /// 编辑组资料 - /// [groupID] 被编辑的群ID - /// [groupName] 新的群名 - /// [notification] 新的公告 - /// [introduction] 新的群介绍 - /// [faceURL] 新的群头像 - /// [ex] 新的额外信息 + .then((value) => Utils.toObj(value, (map) => GroupInfo.fromJson(map))); + + /// Edit group information Future setGroupInfo({ required String groupID, String? groupName, @@ -223,8 +209,7 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 查询组信息 - /// [groupIDList] 组ID列表 + /// Query group information Future> getGroupsInfo({ required List groupIDList, String? operationID, @@ -236,11 +221,10 @@ class GroupManager { 'groupIDList': groupIDList, 'operationID': Utils.checkOperationID(operationID), })) - .then( - (value) => Utils.toList(value, (map) => GroupInfo.fromJson(map))); + .then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map))); - /// 申请加入组,需要通过管理员/群组同意。 - /// [joinSource] 2:通过邀请 3:通过搜索 4:通过二维码 + /// Apply to join a group, requiring approval from an administrator or the group. + /// [joinSource] 2: Invited, 3: Searched, 4: Using a QR code Future joinGroup({ required String groupID, String? reason, @@ -256,7 +240,7 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 退出组 + /// Exit a group Future quitGroup({ required String groupID, String? operationID, @@ -268,9 +252,9 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 转移组拥有者权限 - /// [groupID] 组ID - /// [userID] 新拥有者ID + // (Continuing the code) + + /// Transfer group ownership Future transferGroupOwner({ required String groupID, required String userID, @@ -284,34 +268,26 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 作为群主或者管理员,收到的群成员入群申请 - Future> getGroupApplicationListAsRecipient( - {String? operationID}) => - _channel - .invokeMethod( - 'getGroupApplicationListAsRecipient', - _buildParam({ - 'operationID': Utils.checkOperationID(operationID), - })) - .then((value) => - Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map))); + /// Handle group membership applications received as a group owner or administrator + Future> getGroupApplicationListAsRecipient({String? operationID}) => _channel + .invokeMethod( + 'getGroupApplicationListAsRecipient', + _buildParam({ + 'operationID': Utils.checkOperationID(operationID), + })) + .then((value) => Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map))); - /// 获取自己发出的入群申请记录 - Future> getGroupApplicationListAsApplicant( - {String? operationID}) => - _channel - .invokeMethod( - 'getGroupApplicationListAsApplicant', - _buildParam({ - 'operationID': Utils.checkOperationID(operationID), - })) - .then((value) => - Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map))); + /// Get the list of group membership applications sent by the user + Future> getGroupApplicationListAsApplicant({String? operationID}) => _channel + .invokeMethod( + 'getGroupApplicationListAsApplicant', + _buildParam({ + 'operationID': Utils.checkOperationID(operationID), + })) + .then((value) => Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map))); - /// 管理员或者群主同意某人进入某群 - /// 注:主动申请入群需要通过管理员/群组处理,被别人拉入群不需要管理员/群组处理 - /// [groupID] 组id - /// [userID] 申请者用户ID + /// Accept a group membership application as an administrator or group owner + /// Note: Membership applications require approval from administrators or the group. Future acceptGroupApplication({ required String groupID, required String userID, @@ -327,11 +303,8 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 管理员或者群主拒绝某人进入某群 - /// 注:主动申请入群需要通过管理员/群组处理,被别人拉入群不需要管理员/群组处理 - /// [groupID] 组id - /// [userID] 申请者用户ID - /// [handleMsg] 说明 + /// Refuse a group membership application as an administrator or group owner + /// Note: Membership applications require approval from administrators or the group. Future refuseGroupApplication({ required String groupID, required String userID, @@ -347,8 +320,10 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 解散群 - /// [groupID] 群ID + // (Continuing the code) + + /// Dissolve a group + /// [groupID] Group ID Future dismissGroup({ required String groupID, String? operationID, @@ -360,9 +335,9 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 开启群禁言,所有群成员禁止发言 - /// [groupID] 将开启群禁言的组ID - /// [mute] true:开启,false:关闭 + /// Enable or disable group mute, preventing all group members from sending messages + /// [groupID] Group ID + /// [mute] true: Enable, false: Disable Future changeGroupMute({ required String groupID, required bool mute, @@ -376,10 +351,10 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 禁言群成员 - /// [groupID] 群ID - /// [userID] 将被禁言的成员ID - /// [seconds] 被禁言的时间s,设置为0则为解除禁言 + /// Mute a group member + /// [groupID] Group ID + /// [userID] Member ID to mute + /// [seconds] Duration of the mute in seconds (set to 0 to unmute) Future changeGroupMemberMute({ required String groupID, required String userID, @@ -395,10 +370,10 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 设置群成员昵称 - /// [groupID] 群ID - /// [userID] 群成员的用户ID - /// [groupNickname] 群昵称 + /// Set the nickname of a group member + /// [groupID] Group ID + /// [userID] User ID of the group member + /// [groupNickname] Group nickname Future setGroupMemberNickname({ required String groupID, required String userID, @@ -414,10 +389,10 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 查询群 - /// [keywordList] 搜索关键词,目前仅支持一个关键词搜索,不能为空 - /// [isSearchGroupID] 是否以关键词搜索群ID(注:两个不可以同时为false),为空默认false - /// [isSearchGroupName] 是否以关键词搜索群名字,为空默认false + /// Query a group + /// [keywordList] Search keywords; currently, only one keyword is supported, and it cannot be empty. + /// [isSearchGroupID] Whether to search by group ID (Note: cannot set both to false at the same time); defaults to false if not set. + /// [isSearchGroupName] Whether to search by group name; defaults to false if not set. Future> searchGroups({ List keywordList = const [], bool isSearchGroupID = false, @@ -435,13 +410,12 @@ class GroupManager { }, 'operationID': Utils.checkOperationID(operationID), })) - .then( - (value) => Utils.toList(value, (map) => GroupInfo.fromJson(map))); + .then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map))); - /// 设置群成员权限 - /// [groupID] 群ID - /// [userID] 群成员的用户ID - /// [roleLevel] 角色等级,参考[GroupRoleLevel] + /// Set group member role + /// [groupID] Group ID + /// [userID] User ID of the group member + /// [roleLevel] Role level; see [GroupRoleLevel] Future setGroupMemberRoleLevel({ required String groupID, required String userID, @@ -457,13 +431,7 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 根据加入时间分页获取组成员列表 - /// [groupID] 群ID - /// [joinTimeBegin] 加入开始时间 - /// [joinTimeEnd] 加入结束时间 - /// [offset] 开始下标 - /// [count] 总数 - /// [excludeUserIDList] 排除的用户 + /// Get a group member list based on join time Future> getGroupMemberListByJoinTime({ required String groupID, int offset = 0, @@ -485,12 +453,11 @@ class GroupManager { 'excludeUserIDList': excludeUserIDList, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => - Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); + .then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); - /// 进群验证设置 - /// [groupID] 群ID - /// [needVerification] 进群设置,参考[GroupVerification]类 + /// Set group verification for joining + /// [groupID] Group ID + /// [needVerification] Verification setting; see [GroupVerification] class Future setGroupVerification({ required String groupID, required int needVerification, @@ -504,9 +471,9 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 不允许通过群获取成员资料 - /// [groupID] 群ID - /// [status] 0:关闭,1:打开 + /// Allow/disallow members to view each other's information through the group + /// [groupID] Group ID + /// [status] 0: Disable, 1: Enable Future setGroupLookMemberInfo({ required String groupID, required int status, @@ -520,9 +487,9 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 不允许通过群添加好友 - /// [groupID] 群ID - /// [status] 0:关闭,1:打开 + /// Allow/disallow members to add friends through the group + /// [groupID] Group ID + /// [status] 0: Disable, 1: Enable Future setGroupApplyMemberFriend({ required String groupID, required int status, @@ -536,8 +503,8 @@ class GroupManager { 'operationID': Utils.checkOperationID(operationID), })); - /// 获取群拥有者,管理员 - /// [groupId] 群ID + /// Get group owners and administrators + /// [groupId] Group ID Future> getGroupOwnerAndAdmin({ required String groupID, String? operationID, @@ -549,16 +516,15 @@ class GroupManager { 'groupID': groupID, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => - Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); - - /// 查询群 - /// [groupID] 群id - /// [keywordList] 搜索关键词,目前仅支持一个关键词搜索,不能为空 - /// [isSearchUserID] 是否以关键词搜成员id - /// [isSearchMemberNickname] 是否以关键词搜索成员昵称 - /// [offset] 开始index - /// [count] 每次获取的总数 + .then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); + + /// Search for group members + /// [groupID] Group ID + /// [keywordList] Search keywords; currently, only one keyword is supported, and it cannot be empty. + /// [isSearchUserID] Whether to search by member ID + /// [isSearchMemberNickname] Whether to search by member nickname + /// [offset] Start index + /// [count] Total count to retrieve Future> searchGroupMembers({ required String groupID, List keywordList = const [], @@ -582,16 +548,15 @@ class GroupManager { }, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => - Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); - - /// 查询群 - /// [groupID] 群id - /// [keywordList] 搜索关键词,目前仅支持一个关键词搜索,不能为空 - /// [isSearchUserID] 是否以关键词搜成员id - /// [isSearchMemberNickname] 是否以关键词搜索成员昵称 - /// [offset] 开始index - /// [count] 每次获取的总数 + .then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); + + /// Query a group + /// [groupID] Group ID + /// [keywordList] Search keyword, currently only supports searching with one keyword, and it cannot be empty + /// [isSearchUserID] Whether to search member IDs with the keyword + /// [isSearchMemberNickname] Whether to search member nicknames with the keyword + /// [offset] Starting index + /// [count] Total number to retrieve each time Future> searchGroupMembersListMap({ required String groupID, List keywordList = const [], @@ -617,7 +582,7 @@ class GroupManager { })) .then((value) => Utils.toListMap(value)); - /// 修改GroupMemberInfo ex字段 + /// Modify the GroupMemberInfo ex field Future setGroupMemberInfo({ required String groupID, required String userID, @@ -634,7 +599,6 @@ class GroupManager { }, 'operationID': Utils.checkOperationID(operationID), })); - static Map _buildParam(Map param) { param["ManagerName"] = "groupManager"; log('param: $param'); diff --git a/lib/src/manager/im_manager.dart b/lib/src/manager/im_manager.dart index 6d6c10c..19b7a4e 100644 --- a/lib/src/manager/im_manager.dart +++ b/lib/src/manager/im_manager.dart @@ -64,8 +64,9 @@ class IMManager { userManager.listener.selfInfoUpdated(userInfo); break; case 'onUserStatusChanged': - final status = Utils.toObj(data, (map) => UserStatusInfo.fromJson(map)); - userManager.listener.userStatusChanged(status); + final status = + Utils.toObj(data, (map) => UserStatusInfo.fromJson(map)); + userManager.listener.userStatusChanged(status); break; } } else if (call.method == ListenerType.groupListener) { @@ -73,19 +74,23 @@ class IMManager { dynamic data = call.arguments['data']; switch (type) { case 'onGroupApplicationAccepted': - final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map)); + final i = Utils.toObj( + data, (map) => GroupApplicationInfo.fromJson(map)); groupManager.listener.groupApplicationAccepted(i); break; case 'onGroupApplicationAdded': - final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map)); + final i = Utils.toObj( + data, (map) => GroupApplicationInfo.fromJson(map)); groupManager.listener.groupApplicationAdded(i); break; case 'onGroupApplicationDeleted': - final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map)); + final i = Utils.toObj( + data, (map) => GroupApplicationInfo.fromJson(map)); groupManager.listener.groupApplicationDeleted(i); break; case 'onGroupApplicationRejected': - final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map)); + final i = Utils.toObj( + data, (map) => GroupApplicationInfo.fromJson(map)); groupManager.listener.groupApplicationRejected(i); break; case 'onGroupDismissed': @@ -97,15 +102,18 @@ class IMManager { groupManager.listener.groupInfoChanged(i); break; case 'onGroupMemberAdded': - final i = Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map)); + final i = + Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map)); groupManager.listener.groupMemberAdded(i); break; case 'onGroupMemberDeleted': - final i = Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map)); + final i = + Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map)); groupManager.listener.groupMemberDeleted(i); break; case 'onGroupMemberInfoChanged': - final i = Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map)); + final i = + Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map)); groupManager.listener.groupMemberInfoChanged(i); break; case 'onJoinedGroupAdded': @@ -133,31 +141,22 @@ class IMManager { break; case 'onRecvC2CReadReceipt': var value = call.arguments['data']['msgReceiptList']; - var list = Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map)); + var list = + Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map)); messageManager.msgListener.recvC2CReadReceipt(list); break; case 'onRecvGroupReadReceipt': var value = call.arguments['data']['groupMsgReceiptList']; - var list = Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map)); + var list = + Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map)); messageManager.msgListener.recvGroupReadReceipt(list); break; - case 'onRecvMessageExtensionsAdded': - var msgID = call.arguments['data']['msgID']; - var value = call.arguments['data']['reactionExtensionList']; - var list = Utils.toList(value, (map) => KeyValue.fromJson(map)); - messageManager.msgListener.recvMessageExtensionsAdded(msgID, list); - break; - case 'onRecvMessageExtensionsChanged': - var msgID = call.arguments['data']['msgID']; - var value = call.arguments['data']['reactionExtensionList']; - var list = Utils.toList(value, (map) => KeyValue.fromJson(map)); - messageManager.msgListener.recvMessageExtensionsChanged(msgID, list); - break; case 'onRecvMessageExtensionsDeleted': var msgID = call.arguments['data']['msgID']; var value = call.arguments['data']['reactionExtensionKeyList']; var list = Utils.toList(value, (map) => '$map'); - messageManager.msgListener.recvMessageExtensionsDeleted(msgID, list); + messageManager.msgListener + .recvMessageExtensionsDeleted(msgID, list); break; case 'onRecvNewMessage': @@ -199,15 +198,18 @@ class IMManager { conversationManager.listener.syncServerFailed(); break; case 'onNewConversation': - var list = Utils.toList(data, (map) => ConversationInfo.fromJson(map)); + var list = + Utils.toList(data, (map) => ConversationInfo.fromJson(map)); conversationManager.listener.newConversation(list); break; case 'onConversationChanged': - var list = Utils.toList(data, (map) => ConversationInfo.fromJson(map)); + var list = + Utils.toList(data, (map) => ConversationInfo.fromJson(map)); conversationManager.listener.conversationChanged(list); break; case 'onTotalUnreadMessageCountChanged': - conversationManager.listener.totalUnreadMessageCountChanged(data ?? 0); + conversationManager.listener + .totalUnreadMessageCountChanged(data ?? 0); break; } } else if (call.method == ListenerType.friendListener) { @@ -228,19 +230,23 @@ class IMManager { friendshipManager.listener.friendAdded(u); break; case 'onFriendApplicationAccepted': - final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map)); + final u = Utils.toObj( + data, (map) => FriendApplicationInfo.fromJson(map)); friendshipManager.listener.friendApplicationAccepted(u); break; case 'onFriendApplicationAdded': - final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map)); + final u = Utils.toObj( + data, (map) => FriendApplicationInfo.fromJson(map)); friendshipManager.listener.friendApplicationAdded(u); break; case 'onFriendApplicationDeleted': - final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map)); + final u = Utils.toObj( + data, (map) => FriendApplicationInfo.fromJson(map)); friendshipManager.listener.friendApplicationDeleted(u); break; case 'onFriendApplicationRejected': - final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map)); + final u = Utils.toObj( + data, (map) => FriendApplicationInfo.fromJson(map)); friendshipManager.listener.friendApplicationRejected(u); break; case 'onFriendDeleted': @@ -257,16 +263,8 @@ class IMManager { String data = call.arguments['data']; switch (type) { case 'onRecvCustomBusinessMessage': - messageManager.customBusinessListener?.recvCustomBusinessMessage(data); - break; - } - } else if (call.method == ListenerType.messageKvInfoListener) { - String type = call.arguments['type']; - String data = call.arguments['data']; - switch (type) { - case 'onMessageKvInfoChanged': - final list = Utils.toList(data, (map) => MessageKv.fromJson(map)).toList(); - messageManager.messageKvInfoListener?.messageKvInfoChanged(list); + messageManager.customBusinessListener + ?.recvCustomBusinessMessage(data); break; } } else if (call.method == ListenerType.listenerForService) { @@ -274,19 +272,23 @@ class IMManager { String data = call.arguments['data']; switch (type) { case 'onFriendApplicationAccepted': - final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map)); + final u = Utils.toObj( + data, (map) => FriendApplicationInfo.fromJson(map)); _listenerForService?.friendApplicationAccepted(u); break; case 'onFriendApplicationAdded': - final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map)); + final u = Utils.toObj( + data, (map) => FriendApplicationInfo.fromJson(map)); _listenerForService?.friendApplicationAdded(u); break; case 'onGroupApplicationAccepted': - final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map)); + final i = Utils.toObj( + data, (map) => GroupApplicationInfo.fromJson(map)); _listenerForService?.groupApplicationAccepted(i); break; case 'onGroupApplicationAdded': - final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map)); + final i = Utils.toObj( + data, (map) => GroupApplicationInfo.fromJson(map)); _listenerForService?.groupApplicationAdded(i); break; case 'onRecvNewMessage': @@ -334,7 +336,8 @@ class IMManager { int fileSize = data['fileSize']; int streamSize = data['streamSize']; int storageSize = data['storageSize']; - _uploadFileListener?.uploadProgress(id, fileSize, streamSize, storageSize); + _uploadFileListener?.uploadProgress( + id, fileSize, streamSize, storageSize); break; case 'uploadID': String id = data['id']; @@ -346,26 +349,28 @@ class IMManager { int index = data['index']; int partSize = data['partSize']; String partHash = data['partHash']; - _uploadFileListener?.uploadPartComplete(id, index, partSize, partHash); + _uploadFileListener?.uploadPartComplete( + id, index, partSize, partHash); break; } } } catch (error, stackTrace) { - Logger.print("回调失败了。${call.method} ${call.arguments['type']} ${call.arguments['data']} $error $stackTrace"); + Logger.print( + "回调失败了。${call.method} ${call.arguments['type']} ${call.arguments['data']} $error $stackTrace"); } return Future.value(null); }); } - /// 初始化SDK - /// [platform] 平台编号[IMPlatform] - /// [apiAddr] SDK api地址 - /// [wsAddr] SDK websocket地址 - /// [dataDir] SDK数据库存储目录 - /// [objectStorage] 存储对象 cos/minio - /// [logLevel] 日志 1不打印 - /// [enabledEncryption] true:加密 - /// [enabledCompression] true:压缩 + /// Initialize the SDK + /// [platform] Platform ID [IMPlatform] + /// [apiAddr] SDK API address + /// [wsAddr] SDK WebSocket address + /// [dataDir] SDK database storage directory + /// [objectStorage] Object storage minio + /// [logLevel] Log level, 1: no printing + /// [enabledEncryption] true: encryption + /// [enabledCompression] true: compression Future initSDK({ required int platformID, required String apiAddr, @@ -373,46 +378,41 @@ class IMManager { required String dataDir, required OnConnectListener listener, int logLevel = 6, - String objectStorage = 'cos', - // String? encryptionKey, - // bool isNeedEncryption = false, - // bool isCompression = false, - // bool isExternalExtensions = false, + String objectStorage = 'minio', + bool isCompression = false, bool isLogStandardOutput = true, String? logFilePath, String? operationID, }) { this._connectListener = listener; return _channel.invokeMethod( - 'initSDK', - _buildParam( - { - "platformID": platformID, - "apiAddr": apiAddr, - "wsAddr": wsAddr, - "dataDir": dataDir, - "logLevel": logLevel, - "objectStorage": objectStorage, - // "encryptionKey": encryptionKey, - // "isNeedEncryption": isNeedEncryption, - // "isCompression": isCompression, - // "isExternalExtensions": isExternalExtensions, - "isLogStandardOutput": isLogStandardOutput, - "logFilePath": logFilePath, - "operationID": Utils.checkOperationID(operationID), - }, - )); + 'initSDK', + _buildParam( + { + "platformID": platformID, + "apiAddr": apiAddr, + "wsAddr": wsAddr, + "dataDir": dataDir, + "logLevel": logLevel, + "objectStorage": objectStorage, + "isCompression": isCompression, + "isLogStandardOutput": isLogStandardOutput, + "logFilePath": logFilePath, + "operationID": Utils.checkOperationID(operationID), + }, + ), + ); } - /// 反初始化SDK + /// Deinitialize the SDK Future unInitSDK() { return _channel.invokeMethod('unInitSDK', _buildParam({})); } - /// 登录 - /// [userID] 用户id - /// [token] 登录token,从业务服务器上获取 - /// [defaultValue] 获取失败后使用的默认值 + /// Login + /// [userID] User ID + /// [token] Login token obtained from the business server + /// [defaultValue] Default value to use if login fails Future login({ required String userID, required String token, @@ -422,7 +422,7 @@ class IMManager { }) async { int? status; if (checkLoginStatus) { - // 1: logout 2: logging 3:logged + // 1: logout 2: logging 3: logged status = await getLoginStatus(); } if (status != LoginStatus.logging && status != LoginStatus.logged) { @@ -450,36 +450,38 @@ class IMManager { // return uInfo; } - /// 登出 + /// Logout Future logout({String? operationID}) async { var value = await _channel.invokeMethod( - 'logout', - _buildParam({ - 'operationID': Utils.checkOperationID(operationID), - })); + 'logout', + _buildParam({ + 'operationID': Utils.checkOperationID(operationID), + }), + ); this.isLogined = false; this.token = null; return value; } - /// 获取登录状态 - /// 1: logout 2: logging 3:logged + /// Get login status + /// 1: logout 2: logging 3: logged Future getLoginStatus({ String? operationID, }) => _channel.invokeMethod( - 'getLoginStatus', - _buildParam({ - 'operationID': Utils.checkOperationID(operationID), - })); + 'getLoginStatus', + _buildParam({ + 'operationID': Utils.checkOperationID(operationID), + }), + ); - /// 获取当前登录用户id + /// Get the current logged-in user ID Future getLoginUserID() async => userID; - /// 获取当前登录用户信息 + /// Get the current logged-in user information Future getLoginUserInfo() async => userInfo; - ///[id] 跟 [OnUploadFileListener] id一致,区分是哪个文件的回调 + /// [id] Same as [OnUploadFileListener] ID, to distinguish which file callback it is Future uploadFile({ required String id, required String filePath, @@ -489,50 +491,30 @@ class IMManager { String? operationID, }) => _channel.invokeMethod( - 'uploadFile', - _buildParam({ - 'id': id, - 'filePath': filePath, - 'name': fileName, - 'contentType': contentType, - 'cause': cause, - 'operationID': Utils.checkOperationID(operationID), - })); + 'uploadFile', + _buildParam({ + 'id': id, + 'filePath': filePath, + 'name': fileName, + 'contentType': contentType, + 'cause': cause, + 'operationID': Utils.checkOperationID(operationID), + }), + ); - /// 更新firebase客户端注册token - /// [fcmToken] firebase token + /// Update the Firebase client registration token + /// [fcmToken] Firebase token Future updateFcmToken({ required String fcmToken, String? operationID, }) => _channel.invokeMethod( - 'updateFcmToken', - _buildParam({ - 'fcmToken': fcmToken, - 'operationID': Utils.checkOperationID(operationID), - })); - - /// 标记app处于后台 - // Future setAppBackgroundStatus({ - // required bool isBackground, - // String? operationID, - // }) => - // _channel.invokeMethod( - // 'setAppBackgroundStatus', - // _buildParam({ - // 'isBackground': isBackground, - // 'operationID': Utils.checkOperationID(operationID), - // })); - - /// 网络改变 - // Future networkStatusChanged({ - // String? operationID, - // }) => - // _channel.invokeMethod( - // 'networkStatusChanged', - // _buildParam({ - // 'operationID': Utils.checkOperationID(operationID), - // })); + 'updateFcmToken', + _buildParam({ + 'fcmToken': fcmToken, + 'operationID': Utils.checkOperationID(operationID), + }), + ); void setUploadFileListener(OnUploadFileListener listener) { _uploadFileListener = listener; diff --git a/lib/src/manager/im_message_manager.dart b/lib/src/manager/im_message_manager.dart index 797eab6..db7dbff 100644 --- a/lib/src/manager/im_message_manager.dart +++ b/lib/src/manager/im_message_manager.dart @@ -4,15 +4,13 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; class MessageManager { MethodChannel _channel; - // List advancedMsgListeners = List.empty(growable: true); OnMsgSendProgressListener? msgSendProgressListener; late OnAdvancedMsgListener msgListener; OnCustomBusinessListener? customBusinessListener; - OnMessageKvInfoListener? messageKvInfoListener; MessageManager(this._channel); - /// 消息监听 + /// Message listener Future setAdvancedMsgListener(OnAdvancedMsgListener listener) { this.msgListener = listener; // advancedMsgListeners.add(listener); @@ -23,16 +21,16 @@ class MessageManager { })); } - /// 消息发送进度监听 + /// Message send progress listener void setMsgSendProgressListener(OnMsgSendProgressListener listener) { msgSendProgressListener = listener; } - /// 发送消息 - /// [message] 消息体 - /// [userID] 接收消息的用户id - /// [groupID] 接收消息的组id - /// [offlinePushInfo] 离线消息显示内容 + /// Send a message + /// [message] Message content + /// [userID] User ID of the recipient + /// [groupID] Group ID of the recipient + /// [offlinePushInfo] Offline message display content Future sendMessage({ required Message message, required OfflinePushInfo offlinePushInfo, @@ -52,8 +50,8 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 删除本地消息 - /// [message] 被删除的消息体 + /// Delete a message from local storage + /// [message] Message to be deleted Future deleteMessageFromLocalStorage({ required String conversationID, required String clientMsgID, @@ -68,8 +66,8 @@ class MessageManager { })); /// core-sdk: DeleteMessage - /// 删除本地跟服务器的指定的消息 - /// [message] 被删除的消息 + /// Delete a specified message from local and server + /// [message] Message to be deleted Future deleteMessageFromLocalAndSvr({ required String conversationID, required String clientMsgID, @@ -83,7 +81,7 @@ class MessageManager { "operationID": Utils.checkOperationID(operationID), })); - /// 删除本地所有聊天记录 + /// Delete all local chat records Future deleteAllMsgFromLocal({ String? operationID, }) => @@ -93,7 +91,7 @@ class MessageManager { "operationID": Utils.checkOperationID(operationID), })); - /// 删除本地跟服务器所有聊天记录 + /// Delete all chat records from local and server Future deleteAllMsgFromLocalAndSvr({ String? operationID, }) => @@ -103,10 +101,10 @@ class MessageManager { "operationID": Utils.checkOperationID(operationID), })); - /// 插入单聊消息到本地 - /// [receiverID] 接收者id - /// [senderID] 发送者id - /// [message] 消息体 + /// Insert a single chat message into local storage + /// [receiverID] Receiver's ID + /// [senderID] Sender's ID + /// [message] Message content Future insertSingleMessageToLocalStorage({ String? receiverID, String? senderID, @@ -124,10 +122,10 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 插入群聊消息到本地 - /// [groupID] 群id - /// [senderID] 发送者id - /// [message] 消息体 + /// Insert a group chat message into local storage + /// [groupID] Group ID + /// [senderID] Sender's ID + /// [message] Message content Future insertGroupMessageToLocalStorage({ String? groupID, String? senderID, @@ -145,8 +143,8 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 正在输入提示 - /// [msgTip] 自定义内容 + /// Typing status update + /// [msgTip] Custom content Future typingStatusUpdate({ required String userID, String? msgTip, @@ -160,7 +158,7 @@ class MessageManager { "operationID": Utils.checkOperationID(operationID), })); - /// 创建文本消息 + /// Create a text message Future createTextMessage({ required String text, String? operationID, @@ -174,11 +172,11 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建@消息 - /// [text] 输入内容 - /// [atUserIDList] 被@到的userID集合 - /// [atUserInfoList] userID跟nickname映射关系,用在界面显示时将id替换为nickname - /// [quoteMessage] 引用消息(被回复的消息) + /// Create an @ message + /// [text] Input content + /// [atUserIDList] Collection of userIDs being mentioned + /// [atUserInfoList] Mapping of userID to nickname, used for displaying nicknames instead of IDs in the user interface + /// [quoteMessage] Quoted message (the message being replied to) Future createTextAtMessage({ required String text, required List atUserIDList, @@ -199,8 +197,8 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建图片消息 - /// [imagePath] 路径 + /// Create an image message + /// [imagePath] Path Future createImageMessage({ required String imagePath, String? operationID, @@ -215,8 +213,8 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建图片消息 - /// [imagePath] 路径 + /// Create an image message from a full path + /// [imagePath] Path Future createImageMessageFromFullPath({ required String imagePath, String? operationID, @@ -231,9 +229,9 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建语音消息 - /// [soundPath] 路径 - /// [duration] 时长s + /// Create a sound message + /// [soundPath] Path + /// [duration] Duration in seconds Future createSoundMessage({ required String soundPath, required int duration, @@ -250,9 +248,9 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建语音消息 - /// [soundPath] 路径 - /// [duration] 时长s + /// Create a sound message from a full path + /// [soundPath] Path + /// [duration] Duration in seconds Future createSoundMessageFromFullPath({ required String soundPath, required int duration, @@ -269,11 +267,11 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建视频消息 - /// [videoPath] 路径 - /// [videoType] 视频mime类型 - /// [duration] 时长s - /// [snapshotPath] 默认站位图路径 + /// Create a video message + /// [videoPath] Path + /// [videoType] Video MIME type + /// [duration] Duration in seconds + /// [snapshotPath] Default snapshot image path Future createVideoMessage({ required String videoPath, required String videoType, @@ -293,11 +291,11 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建视频消息 - /// [videoPath] 路径 - /// [videoType] 视频mime类型 - /// [duration] 时长s - /// [snapshotPath] 默认站位图路径 + /// Create a video message from a full path + /// [videoPath] Path + /// [videoType] Video MIME type + /// [duration] Duration in seconds + /// [snapshotPath] Default snapshot image path Future createVideoMessageFromFullPath({ required String videoPath, required String videoType, @@ -317,9 +315,9 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建文件消息 - /// [filePath] 路径 - /// [fileName] 文件名 + /// Create a file message + /// [filePath] Path + /// [fileName] File name Future createFileMessage({ required String filePath, required String fileName, @@ -336,9 +334,9 @@ class MessageManager { .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); } - /// 创建文件消息 - /// [filePath] 路径 - /// [fileName] 文件名 + /// Create a file message from a full path + /// [filePath] Path + /// [fileName] File name Future createFileMessageFromFullPath({ required String filePath, required String fileName, @@ -354,10 +352,10 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建合并消息 - /// [messageList] 被选中的消息 - /// [title] 摘要标题 - /// [summaryList] 摘要内容 + /// Create a merged message + /// [messageList] Selected messages + /// [title] Summary title + /// [summaryList] Summary content Future createMergerMessage({ required List messageList, required String title, @@ -375,8 +373,8 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建转发消息 - /// [message] 被转发的消息 + /// Create a forwarded message + /// [message] Message to be forwarded Future createForwardMessage({ required Message message, String? operationID, @@ -391,10 +389,10 @@ class MessageManager { .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); } - /// 创建位置消息 - /// [latitude] 纬度 - /// [longitude] 经度 - /// [description] 自定义描述信息 + /// Create a location message + /// [latitude] Latitude + /// [longitude] Longitude + /// [description] Custom description Future createLocationMessage({ required double latitude, required double longitude, @@ -412,10 +410,10 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建自定义消息 - /// [data] 自定义数据 - /// [extension] 自定义扩展内容 - /// [description] 自定义描述内容 + /// Create a custom message + /// [data] Custom data + /// [extension] Custom extension content + /// [description] Custom description content Future createCustomMessage({ required String data, required String extension, @@ -433,9 +431,9 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建引用消息 - /// [text] 回复的内容 - /// [quoteMsg] 被回复的消息 + /// Create a quoted message + /// [text] Reply content + /// [quoteMsg] Message being replied to Future createQuoteMessage({ required String text, required Message quoteMsg, @@ -451,8 +449,8 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建卡片消息 - /// [data] 自定义数据 + /// Create a card message + /// [data] Custom data Future createCardMessage({ required String userID, required String nickname, @@ -474,9 +472,9 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建自定义表情消息 - /// [index] 位置表情,根据index匹配 - /// [data] url表情,直接使用url显示 + /// Create a custom emoji message + /// [index] Positional emoji, matched based on index + /// [data] URL emoji, displayed directly using the URL Future createFaceMessage({ int index = -1, String? data, @@ -492,16 +490,16 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 搜索消息 - /// [conversationID] 根据会话查询,如果是全局搜索传null - /// [keywordList] 搜索关键词列表,目前仅支持一个关键词搜索 - /// [keywordListMatchType] 关键词匹配模式,1代表与,2代表或,暂时未用 - /// [senderUserIDList] 指定消息发送的uid列表 暂时未用 - /// [messageTypeList] 消息类型列表 - /// [searchTimePosition] 搜索的起始时间点。默认为0即代表从现在开始搜索。UTC 时间戳,单位:秒 - /// [searchTimePeriod] 从起始时间点开始的过去时间范围,单位秒。默认为0即代表不限制时间范围,传24x60x60代表过去一天 - /// [pageIndex] 当前页数 - /// [count] 每页数量 + /// Search messages + /// [conversationID] Query based on conversation, pass null for global search + /// [keywordList] Search keyword list, currently supports searching with a single keyword + /// [keywordListMatchType] Keyword matching mode, 1 means AND, 2 means OR (currently unused) + /// [senderUserIDList] List of UIDs for messages sent (currently unused) + /// [messageTypeList] Message type list + /// [searchTimePosition] Start time point for searching. Defaults to 0, meaning searching from now. UTC timestamp, in seconds + /// [searchTimePeriod] Time range in the past from the start time point, in seconds. Defaults to 0, meaning no time range limitation. Pass 24x60x60 to represent the past day + /// [pageIndex] Current page number + /// [count] Number of messages per page Future searchLocalMessages({ String? conversationID, List keywordList = const [], @@ -531,10 +529,11 @@ class MessageManager { }, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toObj(value, (map) => SearchResult.fromJson(map))); + .then((value) => + Utils.toObj(value, (map) => SearchResult.fromJson(map))); - /// 撤回消息 - /// [message] 被撤回的消息体 + /// Revoke a message + /// [message] The message to be revoked Future revokeMessage({ required String conversationID, required String clientMsgID, @@ -548,9 +547,9 @@ class MessageManager { "operationID": Utils.checkOperationID(operationID), })); - /// 标记消息已读 - /// [conversationID] 会话ID - /// [messageIDList] 被标记的消息clientMsgID + /// Mark messages as read + /// [conversationID] Conversation ID + /// [messageIDList] List of clientMsgIDs of messages to be marked as read Future markMessagesAsReadByMsgID({ required String conversationID, required List messageIDList, @@ -564,11 +563,11 @@ class MessageManager { "operationID": Utils.checkOperationID(operationID), })); - /// 获取聊天记录(以startMsg为节点,以前的聊天记录) - /// [conversationID] 会话id,查询通知时可用 - /// [startMsg] 从这条消息开始查询[count]条,获取的列表index==length-1为最新消息,所以获取下一页历史记录startMsg=list.first - /// [count] 一次拉取的总数 - /// [lastMinSeq] 第一页消息不用传,获取第二页开始必传 跟[startMsg]一样 + /// Get chat history (messages prior to startMsg) + /// [conversationID] Conversation ID, can be used for querying notifications + /// [startMsg] Query [count] messages starting from this message. The message at index == length - 1 is the latest message, so to get the next page of history, use startMsg = list.first + /// [count] Total number of messages to retrieve in one request + /// [lastMinSeq] Not required for the first page of messages, but necessary for getting the second page of history. Same as [startMsg] Future getAdvancedHistoryMessageList({ String? conversationID, Message? startMsg, @@ -586,12 +585,13 @@ class MessageManager { 'lastMinSeq': lastMinSeq ?? 0, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toObj(value, (map) => AdvancedMessage.fromJson(map))); + .then((value) => + Utils.toObj(value, (map) => AdvancedMessage.fromJson(map))); - /// 获取聊天记录(以startMsg为节点,新收到的聊天记录),用在全局搜索定位某一条消息,然后此条消息后新增的消息 - /// [conversationID] 会话id,查询通知时可用 - /// [startMsg] 从这条消息开始查询[count]条,获取的列表index==length-1为最新消息,所以获取下一页历史记录startMsg=list.last - /// [count] 一次拉取的总数 + /// Get chat history (newly received chat history after startMsg). Used for locating a specific message in global search and then fetching messages received after that message. + /// [conversationID] Conversation ID, can be used for querying notifications + /// [startMsg] Query [count] messages starting from this message. The message at index == length - 1 is the latest message, so to get the next page of history, use startMsg = list.last + /// [count] Total number of messages to retrieve in one request Future getAdvancedHistoryMessageListReverse({ String? conversationID, Message? startMsg, @@ -609,11 +609,12 @@ class MessageManager { 'lastMinSeq': lastMinSeq ?? 0, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toObj(value, (map) => AdvancedMessage.fromJson(map))); + .then((value) => + Utils.toObj(value, (map) => AdvancedMessage.fromJson(map))); - /// 查找消息详细 - /// [conversationID] 会话id - /// [clientMsgIDList] 消息id列表 + /// Find message details + /// [conversationID] Conversation ID + /// [clientMsgIDList] List of message IDs Future findMessageList({ required List searchParams, String? operationID, @@ -625,11 +626,12 @@ class MessageManager { 'searchParams': searchParams.map((e) => e.toJson()).toList(), 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toObj(value, (map) => SearchResult.fromJson(map))); + .then((value) => + Utils.toObj(value, (map) => SearchResult.fromJson(map))); - /// 富文本消息 - /// [text] 输入内容 - /// [list] 富文本消息具体详细 + /// Rich text message + /// [text] Input content + /// [list] Details of the rich text message Future createAdvancedTextMessage({ required String text, List list = const [], @@ -646,10 +648,10 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 富文本消息 - /// [text] 回复的内容 - /// [quoteMsg] 被回复的消息 - /// [list] 富文本消息具体详细 + /// Rich text message with quote + /// [text] Content for the reply + /// [quoteMsg] The message being replied to + /// [list] Details of the rich text message Future createAdvancedQuoteMessage({ required String text, required Message quoteMsg, @@ -667,11 +669,11 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 发送消息 - /// [message] 消息体 [createImageMessageByURL],[createSoundMessageByURL],[createVideoMessageByURL],[createFileMessageByURL] - /// [userID] 接收消息的用户id - /// [groupID] 接收消息的组id - /// [offlinePushInfo] 离线消息显示内容 + /// Send a message + /// [message] Message body [createImageMessageByURL],[createSoundMessageByURL],[createVideoMessageByURL],[createFileMessageByURL] + /// [userID] User ID to receive the message + /// [groupID] Group ID to receive the message + /// [offlinePushInfo] Offline message display content Future sendMessageNotOss({ required Message message, required OfflinePushInfo offlinePushInfo, @@ -691,7 +693,7 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建图片消息 + /// Create an image message by URL Future createImageMessageByURL({ required PictureInfo sourcePicture, required PictureInfo bigPicture, @@ -710,7 +712,7 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建语音消息 + /// Create a sound message Future createSoundMessageByURL({ required SoundElem soundElem, String? operationID, @@ -725,7 +727,7 @@ class MessageManager { ) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建视频消息 + /// Create a video message Future createVideoMessageByURL({ required VideoElem videoElem, String? operationID, @@ -739,7 +741,7 @@ class MessageManager { })) .then((value) => Utils.toObj(value, (map) => Message.fromJson(map))); - /// 创建视频消息 + /// Create a file message Future createFileMessageByURL({ required FileElem fileElem, String? operationID, @@ -775,85 +777,6 @@ class MessageManager { })); } - /// - Future setMessageKvInfoListener(OnMessageKvInfoListener listener) { - this.messageKvInfoListener = listener; - return _channel.invokeMethod('setMessageKvInfoListener', _buildParam({})); - } - - Future> setMessageReactionExtensions({ - required Message message, - List list = const [], - String? operationID, - }) => - _channel - .invokeMethod( - 'setMessageReactionExtensions', - _buildParam({ - 'message': message.toJson(), - 'list': list.map((e) => e.toJson()).toList(), - "operationID": Utils.checkOperationID(operationID), - })) - .then((value) => Utils.toList(value, (map) => TypeKeySetResult.fromJson(map))); - - Future> deleteMessageReactionExtensions({ - required Message message, - List list = const [], - String? operationID, - }) => - _channel - .invokeMethod( - 'deleteMessageReactionExtensions', - _buildParam({ - 'message': message.toJson(), - 'list': list, - "operationID": Utils.checkOperationID(operationID), - })) - .then((value) => Utils.toList(value, (map) => TypeKeySetResult.fromJson(map))); - - Future> getMessageListReactionExtensions({ - List messageList = const [], - String? operationID, - }) => - _channel - .invokeMethod( - 'getMessageListReactionExtensions', - _buildParam({ - 'messageList': messageList.map((e) => e.toJson()).toList(), - "operationID": Utils.checkOperationID(operationID), - })) - .then((value) => Utils.toList(value, (map) => MessageTypeKeyMapping.fromJson(map))); - - Future> addMessageReactionExtensions({ - required Message message, - List list = const [], - String? operationID, - }) => - _channel - .invokeMethod( - 'addMessageReactionExtensions', - _buildParam({ - 'message': message.toJson(), - 'list': list.map((e) => e.toJson()).toList(), - "operationID": Utils.checkOperationID(operationID), - })) - .then((value) => Utils.toList(value, (map) => TypeKeySetResult.fromJson(map))); - - Future> getMessageListSomeReactionExtensions({ - List messageList = const [], - List kvList = const [], - String? operationID, - }) => - _channel - .invokeMethod( - 'getMessageListSomeReactionExtensions', - _buildParam({ - 'messageList': messageList.map((e) => e.toJson()).toList(), - 'list': kvList.map((e) => e.toJson()).toList(), - "operationID": Utils.checkOperationID(operationID), - })) - .then((value) => Utils.toList(value, (map) => MessageTypeKeyMapping.fromJson(map))); - static Map _buildParam(Map param) { param["ManagerName"] = "messageManager"; return param; diff --git a/lib/src/manager/im_user_manager.dart b/lib/src/manager/im_user_manager.dart index 3e27434..924b465 100644 --- a/lib/src/manager/im_user_manager.dart +++ b/lib/src/manager/im_user_manager.dart @@ -7,14 +7,14 @@ class UserManager { UserManager(this._channel); - /// 用户资料改变监听 + /// User profile change listener Future setUserListener(OnUserListener listener) { this.listener = listener; return _channel.invokeMethod('setUserListener', _buildParam({})); } - /// 获取用户资料 - /// [userIDList] 用户ID列表 + /// Get user information + /// [userIDList] List of user IDs Future> getUsersInfo({ required List userIDList, String? operationID, @@ -28,7 +28,7 @@ class UserManager { })) .then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v))); - /// 获取当前登录用户的信息 + /// Get information of the currently logged-in user Future getSelfUserInfo({ String? operationID, }) => @@ -40,20 +40,20 @@ class UserManager { })) .then((value) => Utils.toObj(value, (map) => UserInfo.fromJson(map))); - /// 修改当前登录用户资料 - /// [nickname] 昵称 - /// [faceURL] 头像 - /// [gender] 性别 - /// [appMangerLevel] - /// [phoneNumber] 手机号 - /// [birth] 出生日期 - /// [email] 邮箱 - /// [ex] 扩展字段 + /// Modify the profile of the currently logged-in user + /// [nickname] Nickname + /// [faceURL] Profile picture + /// [gender] Gender + /// [appManagerLevel] + /// [phoneNumber] Phone number + /// [birth] Date of birth + /// [email] Email + /// [ex] Additional fields Future setSelfInfo({ String? nickname, String? faceURL, int? gender, - int? appMangerLevel, + int? appManagerLevel, String? phoneNumber, int? birth, String? email, @@ -67,7 +67,7 @@ class UserManager { 'nickname': nickname, 'faceURL': faceURL, 'gender': gender, - 'appMangerLevel': appMangerLevel, + 'appManagerLevel': appManagerLevel, 'phoneNumber': phoneNumber, 'birth': birth, 'email': email, @@ -86,7 +86,8 @@ class UserManager { 'userIDs': userIDs, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); + .then((value) => + Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); } Future> unsubscribeUsersStatus( @@ -100,7 +101,8 @@ class UserManager { 'userIDs': userIDs, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); + .then((value) => + Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); } Future> getSubscribeUsersStatus({ @@ -112,7 +114,8 @@ class UserManager { _buildParam({ 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); + .then((value) => + Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); } Future> getUserStatus( @@ -126,7 +129,8 @@ class UserManager { 'userIDs': userIDs, 'operationID': Utils.checkOperationID(operationID), })) - .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); + .then((value) => + Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); } Future> getUsersInfoStranger( diff --git a/lib/src/models/conversation_info.dart b/lib/src/models/conversation_info.dart index 43c8450..7cdcdc6 100644 --- a/lib/src/models/conversation_info.dart +++ b/lib/src/models/conversation_info.dart @@ -3,66 +3,67 @@ import 'dart:convert'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; class ConversationInfo { - /// 会话ID + // Unique identifier for the conversation String conversationID; - /// 会话类型[ConversationType] + // Type of the conversation (e.g., single, group, super group) int? conversationType; - /// 参与会话的userID + // User ID in case of a single chat String? userID; - /// 参与会话的groupID + // Group ID in case of a group chat String? groupID; - /// 昵称 + // Display name or nickname String? showName; - /// 头像 + // URL of the user's or group's profile picture String? faceURL; - /// 免打扰 0:正常;1:不接受消息;2:接受在线消息不接受离线消息; + // Message reception option (0: normal, 1: do not accept messages, 2: accept online messages but not offline messages) int? recvMsgOpt; - /// 未读消息数 + // Number of unread messages in the conversation int? unreadCount; - /// 强制提示,[GroupAtType]包含@所有人,@个人以及公告提示 - int? groupAtType; - - /// 会话最新消息内容 + // Latest message in the conversation Message? latestMsg; - /// 最新消息发送时间 + // Timestamp of the latest message int? latestMsgSendTime; - /// 草稿 + // Draft text for the conversation String? draftText; - /// 草稿生成时间 + // Timestamp when the draft text was created int? draftTextTime; - /// 是否置顶 + // Indicates whether the conversation is pinned bool? isPinned; - /// 是否开启了私聊(阅后即焚) + // Indicates whether the conversation is a private chat with features like self-destructing messages bool? isPrivateChat; - /// 可阅读期限 s + // Duration for which messages are readable (in seconds) int? burnDuration; - /// 是否开启定期销毁 + // Indicates whether the conversation has self-destructing messages enabled bool? isMsgDestruct; - /// 定期销毁时间 s + // Timestamp for self-destructing messages (in seconds) int? msgDestructTime; - /// 附加内容 + // Additional data or metadata String? ex; - /// 是否还在组内,如果退群返回true + // Indicates whether the user is no longer in the group (if applicable) bool? isNotInGroup; + // Group @ type, which includes @ all, @ individual, and announcement prompts + int? groupAtType; + + // Constructor to create a ConversationInfo object ConversationInfo({ required this.conversationID, this.conversationType, @@ -115,6 +116,7 @@ class ConversationInfo { msgDestructTime = json['msgDestructTime']; } + // Method to convert the ConversationInfo object to a JSON map Map toJson() { final data = Map(); data['conversationID'] = this.conversationID; @@ -140,16 +142,16 @@ class ConversationInfo { return data; } - /// 是单聊 + // Check if it's a single chat bool get isSingleChat => conversationType == ConversationType.single; - /// 是群聊 + // Check if it's a group chat bool get isGroupChat => conversationType == ConversationType.group || conversationType == ConversationType.superGroup; - /// 是有效的 - bool get isValid => isSingleChat || isGroupChat && !isNotInGroup!; + // Check if it's a valid conversation (not in a group if isNotInGroup is true) + bool get isValid => isSingleChat || (isGroupChat && !isNotInGroup!); @override bool operator ==(Object other) => diff --git a/lib/src/models/group_info.dart b/lib/src/models/group_info.dart index 43dc21f..0eaf5e5 100644 --- a/lib/src/models/group_info.dart +++ b/lib/src/models/group_info.dart @@ -1,56 +1,56 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; -/// 群信息 +/// Group Information class GroupInfo { - /// 群ID + /// Group ID String groupID; - /// 群名 + /// Group Name String? groupName; - /// 群公告 + /// Group Announcement String? notification; - /// 群简介 + /// Group Introduction String? introduction; - /// 群头像 + /// Group Avatar String? faceURL; - /// 拥有者ID + /// Owner's ID String? ownerUserID; - /// 创建时间 + /// Creation Time int? createTime; - /// 群成员数 + /// Number of Group Members int? memberCount; - /// 群状态:0正常,1被封,2解散,3禁言 + /// Group Status: 0 - Normal, 1 - Blocked, 2 - Dissolved, 3 - Muted int? status; - /// 创建者ID + /// Creator's ID String? creatorUserID; - /// 群类型[GroupType] + /// Group Type [GroupType] int? groupType; - /// 扩展字段 + /// Extra Information String? ex; - /// 进群验证方式[GroupVerification] + /// Entry Verification Method [GroupVerification] int? needVerification; - /// 不允许通过群获取成员资料 0:关闭,1:打开 + /// Don't Allow Access to Member Information via the Group: 0 - Disabled, 1 - Enabled int? lookMemberInfo; - /// 不允许通过群添加好友 0:关闭,1:打开 + /// Don't Allow Adding Friends via the Group: 0 - Disabled, 1 - Enabled int? applyMemberFriend; - /// 通知更新时间 + /// Notification Update Time int? notificationUpdateTime; - /// 通知发起人 + /// Notification Initiator String? notificationUserID; GroupInfo({ @@ -74,7 +74,6 @@ class GroupInfo { }); GroupInfo.fromJson(Map json) : groupID = json['groupID'] { - /*groupID = json['groupID'];*/ groupName = json['groupName']; notification = json['notification']; introduction = json['introduction']; @@ -115,7 +114,7 @@ class GroupInfo { return data; } - /// 群类型对应的会话类型 + /// Corresponding Conversation Type for Group Type int get sessionType => groupType == GroupType.general ? ConversationType.group : ConversationType.superGroup; @@ -131,42 +130,42 @@ class GroupInfo { int get hashCode => groupID.hashCode; } -/// 群成员信息 +/// Group Member Information class GroupMembersInfo { - /// 群id + /// Group ID String? groupID; - /// 用户id + /// User ID String? userID; - /// 昵称 + /// Nickname String? nickname; - /// 头像 + /// Avatar String? faceURL; - /// 角色[GroupRoleLevel] + /// Role [GroupRoleLevel] int? roleLevel; - /// 加入时间 + /// Join Time int? joinTime; - /// 入群方式 2:邀请加入 3:搜索加入 4:通过二维码加入 + /// Entry Source: 2 - Invited, 3 - Searched, 4 - QR Code int? joinSource; - /// 操作者id + /// Operator's ID String? operatorUserID; - /// 扩展字段 + /// Extra Information String? ex; - /// 禁言时间s + /// Mute End Time (seconds) int? muteEndTime; - /// - int? appMangerLevel; + /// Application Manager Level + int? appManagerLevel; - /// 邀请人id + /// Inviter's User ID String? inviterUserID; GroupMembersInfo({ @@ -180,7 +179,7 @@ class GroupMembersInfo { this.joinSource, this.operatorUserID, this.muteEndTime, - this.appMangerLevel, + this.appManagerLevel, this.inviterUserID, }); @@ -195,7 +194,7 @@ class GroupMembersInfo { joinSource = json['joinSource']; operatorUserID = json['operatorUserID']; muteEndTime = json['muteEndTime']; - appMangerLevel = json['appMangerLevel']; + appManagerLevel = json['appManagerLevel']; inviterUserID = json['inviterUserID']; } @@ -211,7 +210,7 @@ class GroupMembersInfo { data['joinSource'] = this.joinSource; data['operatorUserID'] = this.operatorUserID; data['muteEndTime'] = this.muteEndTime; - data['appMangerLevel'] = this.appMangerLevel; + data['appManagerLevel'] = this.appManagerLevel; data['inviterUserID'] = this.inviterUserID; return data; } @@ -228,12 +227,12 @@ class GroupMembersInfo { int get hashCode => groupID.hashCode ^ userID.hashCode; } -/// 群成员角色 +/// Group Member Role class GroupMemberRole { - /// 用户ID + /// User ID String? userID; - /// [GroupRoleLevel] 1普通成员, 2群主,3管理员 + /// [GroupRoleLevel] 1: Normal Member, 2: Group Owner, 3: Administrator int? roleLevel; GroupMemberRole({this.userID, this.roleLevel = 1}); @@ -251,78 +250,78 @@ class GroupMemberRole { } } -/// 群申请信息 +/// Group Application Information class GroupApplicationInfo { - /// 群ID + /// Group ID String? groupID; - /// 群昵称 + /// Group Nickname String? groupName; - /// 群公告 + /// Group Announcement String? notification; - /// 群介绍 + /// Group Introduction String? introduction; - /// 群头像 + /// Group Avatar String? groupFaceURL; - /// 群创建时间 + /// Group Creation Time int? createTime; - /// 群状态 + /// Group Status int? status; - /// 创建者id + /// Creator's ID String? creatorUserID; - /// 群类型 + /// Group Type int? groupType; - /// 拥有者id + /// Owner's ID String? ownerUserID; - /// 成员数量 + /// Member Count int? memberCount; - /// 发起入群申请的用户id + /// User ID Initiating the Group Join Request String? userID; - /// 发起入群申请的用户昵称 + /// User's Nickname Initiating the Group Join Request String? nickname; - /// 发起入群申请的用户头像 + /// User's Avatar Initiating the Group Join Request String? userFaceURL; - /// 发起入群申请的用户性别 + /// User's Gender Initiating the Group Join Request int? gender; - /// 处理结果:-1:拒绝,1:同意 + /// Handling Result: -1 - Rejected, 1 - Accepted int? handleResult; - /// 请求说明 + /// Request Description String? reqMsg; - /// 处理结果说明 + /// Handling Result Description String? handledMsg; - /// 请求时间 + /// Request Time int? reqTime; - /// 处理者用户ID + /// Handler User ID String? handleUserID; - /// 处理时间 + /// Handling Time int? handledTime; - /// 扩展信息 + /// Extra Information String? ex; - /// 2:通过邀请 3:通过搜索 4:通过二维码 + /// Join Source: 2 - Invited, 3 - Searched, 4 - QR Code int? joinSource; - /// 邀请进群用户ID + /// Inviting User's ID String? inviterUserID; GroupApplicationInfo({ @@ -409,6 +408,7 @@ class GroupApplicationInfo { } } +/// Group Invitation Result class GroupInviteResult { String? userID; int? result; diff --git a/lib/src/models/meeting_info.dart b/lib/src/models/meeting_info.dart deleted file mode 100644 index b1a565d..0000000 --- a/lib/src/models/meeting_info.dart +++ /dev/null @@ -1,155 +0,0 @@ -class MeetingInfoList { - List? meetingInfoList; - - MeetingInfoList({this.meetingInfoList}); - - MeetingInfoList.fromJson(Map json) { - if (json['meetingInfoList'] != null) { - meetingInfoList = []; - json['meetingInfoList'].forEach((v) { - meetingInfoList!.add(MeetingInfo.fromJson(v)); - }); - } - } - - Map toJson() { - final data = Map(); - if (this.meetingInfoList != null) { - data['meetingInfoList'] = - this.meetingInfoList!.map((v) => v.toJson()).toList(); - } - return data; - } -} - -class MeetingInfo { - String? roomID; - String? meetingName; - String? ex; - String? hostUserID; - List? inviteeUserIDList; //邀请列表 - int? createTime; - int? startTime; - int? endTime; - bool? participantCanUnmuteSelf; //成员是否能自己解除禁言 - bool? participantCanEnableVideo; //成员是否能开启视频 - bool? onlyHostInviteUser; //仅主持人可邀请用户 - bool? onlyHostShareScreen; //仅主持人可共享屏幕 - bool? joinDisableMicrophone; //加入是否默认关麦克风 - bool? joinDisableVideo; //加入是否默认关视频 - bool? isMuteAllVideo; // 是否全员禁用视频 - bool? isMuteAllMicrophone; // 是否全员禁用麦克风 - List? canScreenUserIDList; // 可共享屏幕的ID列表 - List? disableMicrophoneUserIDList; // 当前被禁言麦克风的id列表 - List? disableVideoUserIDList; // 当前禁用视频流的ID列表 - List? pinedUserIDList; // 置顶ID列表 - List? beWatchedUserIDList; // 正在被观看用户列表 - - MeetingInfo({ - this.roomID, - this.meetingName, - this.ex, - this.hostUserID, - this.inviteeUserIDList, - this.createTime, - this.startTime, - this.endTime, - this.participantCanUnmuteSelf, - this.participantCanEnableVideo, - this.onlyHostInviteUser, - this.onlyHostShareScreen, - this.joinDisableMicrophone, - this.joinDisableVideo, - this.isMuteAllVideo, - this.isMuteAllMicrophone, - this.canScreenUserIDList, - this.disableMicrophoneUserIDList, - this.disableVideoUserIDList, - this.pinedUserIDList, - this.beWatchedUserIDList, - }); - - MeetingInfo.fromJson(Map json) { - roomID = json['roomID']; - meetingName = json['meetingName']; - ex = json['ex']; - hostUserID = json['hostUserID']; - inviteeUserIDList = json['inviteeUserIDList'] == null - ? null - : (json['inviteeUserIDList'] as List).cast(); - createTime = json['createTime']; - startTime = json['startTime']; - endTime = json['endTime']; - participantCanUnmuteSelf = json['participantCanUnmuteSelf']; - participantCanEnableVideo = json['participantCanEnableVideo']; - onlyHostInviteUser = json['onlyHostInviteUser']; - onlyHostShareScreen = json['onlyHostShareScreen']; - joinDisableMicrophone = json['joinDisableMicrophone']; - joinDisableVideo = json['joinDisableVideo']; - isMuteAllVideo = json['isMuteAllVideo']; - isMuteAllMicrophone = json['isMuteAllMicrophone']; - canScreenUserIDList = json['canScreenUserIDList'] == null - ? null - : (json['canScreenUserIDList'] as List).cast(); - disableMicrophoneUserIDList = json['disableMicrophoneUserIDList'] == null - ? null - : (json['disableMicrophoneUserIDList'] as List).cast(); - disableVideoUserIDList = json['disableVideoUserIDList'] == null - ? null - : (json['disableVideoUserIDList'] as List).cast(); - pinedUserIDList = json['pinedUserIDList'] == null - ? null - : (json['pinedUserIDList'] as List).cast(); - beWatchedUserIDList = json['beWatchedUserIDList'] == null - ? null - : (json['beWatchedUserIDList'] as List).cast(); - } - - Map toJson() { - final data = {}; - data['roomID'] = roomID; - data['meetingName'] = meetingName; - data['ex'] = ex; - data['hostUserID'] = hostUserID; - data['inviteeUserIDList'] = inviteeUserIDList; - data['createTime'] = createTime; - data['startTime'] = startTime; - data['endTime'] = endTime; - data['participantCanUnmuteSelf'] = participantCanUnmuteSelf; - data['participantCanEnableVideo'] = participantCanEnableVideo; - data['onlyHostInviteUser'] = onlyHostInviteUser; - data['onlyHostShareScreen'] = onlyHostShareScreen; - data['joinDisableMicrophone'] = joinDisableMicrophone; - data['joinDisableVideo'] = joinDisableVideo; - data['isMuteAllVideo'] = isMuteAllVideo; - data['isMuteAllMicrophone'] = isMuteAllMicrophone; - data['canScreenUserIDList'] = canScreenUserIDList; - data['disableMicrophoneUserIDList'] = disableMicrophoneUserIDList; - data['disableVideoUserIDList'] = disableVideoUserIDList; - data['pinedUserIDList'] = pinedUserIDList; - data['beWatchedUserIDList'] = beWatchedUserIDList; - return data; - } -} - -class MeetingStreamEvent { - String? roomID; - String? streamType; - bool? mute; - - MeetingStreamEvent({this.roomID, this.streamType, this.mute}); - - MeetingStreamEvent.fromJson(Map json) { - roomID = json['roomID']; - streamType = json['streamType']; - mute = json['mute']; - } - - Map toJson() { - final Map data = new Map(); - data['roomID'] = this.roomID; - data['streamType'] = this.streamType; - data['mute'] = this.mute; - return data; - } -} diff --git a/lib/src/models/message.dart b/lib/src/models/message.dart index f92370e..81893f0 100644 --- a/lib/src/models/message.dart +++ b/lib/src/models/message.dart @@ -3,116 +3,118 @@ import 'dart:io'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; class Message { - /// 消息id,唯一标识 + /// Message ID, a unique identifier. String? clientMsgID; - /// 服务端生成的id + /// Server-generated ID. String? serverMsgID; - /// 创建时间 + /// Creation time. int? createTime; - /// 发送时间 + /// Sending time. int? sendTime; - /// 会话类型[ConversationType] + /// Conversation type [ConversationType]. int? sessionType; - /// 发送者id + /// Sender's ID. String? sendID; - /// 接收者id + /// Receiver's ID. String? recvID; - /// 来源 + /// Source. int? msgFrom; - /// 消息类型[MessageType] + /// Message type [MessageType]. int? contentType; - /// 平台[Platform] + /// Platform [Platform]. int? senderPlatformID; - /// 发送者昵称 + /// Sender's nickname. String? senderNickname; - /// 发送者头像 + /// Sender's avatar. String? senderFaceUrl; - /// 群ID + /// Group ID. String? groupID; - /// 消息内容 - // String? content; + /// Message content. +// String? content; - /// 消息的seq + /// Message sequence number. int? seq; - /// 是否已读 + /// Whether it's read. bool? isRead; - /// 已读时间 + /// Read time. int? hasReadTime; - /// 消息发送状态[MessageStatus] + /// Message sending status [MessageStatus]. int? status; + /// Is it a reaction. bool? isReact; + /// Is it an external extension. bool? isExternalExtensions; - /// 离线显示内容 + /// Offline display content. OfflinePushInfo? offlinePush; - /// 附加信息 + /// Additional information. String? attachedInfo; - /// 扩展信息 + /// Extended information. String? ex; - /// 自定义扩展信息,目前用于客服端处理消息时间分段 + /// Custom extended information, currently used for message time segmentation on the client side. Map exMap = {}; - /// 图片 + /// Image. PictureElem? pictureElem; - /// 语音 + /// Voice. SoundElem? soundElem; - /// 视频 + /// Video. VideoElem? videoElem; - /// 文件 + /// File. FileElem? fileElem; - /// @信息 + /// @ Information. AtTextElem? atTextElem; - /// 位置 + /// Location. LocationElem? locationElem; - /// 自定义 + /// Custom. CustomElem? customElem; - /// 引用 + /// Quote. QuoteElem? quoteElem; - /// 合并 + /// Merge. MergeElem? mergeElem; - /// 通知 + /// Notification. NotificationElem? notificationElem; - /// 自定义表情 + /// Custom emoji. FaceElem? faceElem; - /// 附加信息 + /// Additional information. AttachedInfoElem? attachedInfoElem; - /// 文本内容 + /// Text content. TextElem? textElem; - /// 个人名片 + /// Business card. CardElem? cardElem; /// @@ -334,27 +336,27 @@ class Message { typingElem = message.typingElem; } - /// 单聊消息 + /// Single chat message bool get isSingleChat => sessionType == ConversationType.single; - /// 群聊消息 + /// Group chat message bool get isGroupChat => sessionType == ConversationType.group || sessionType == ConversationType.superGroup; } -/// 图片消息内容 +/// Image message content class PictureElem { - /// 原路径 + /// Original path String? sourcePath; - /// 原图对象 + /// Original picture object PictureInfo? sourcePicture; - /// 大图对象 + /// Big picture object PictureInfo? bigPicture; - /// 缩率图对象 + /// Thumbnail picture object PictureInfo? snapshotPicture; PictureElem( @@ -392,24 +394,24 @@ class PictureElem { } } -/// 图片信息 +/// Image information class PictureInfo { - /// id + /// ID String? uuid; - /// 图片mime类型 + /// Image MIME type String? type; - /// 大小 + /// Size int? size; - /// 宽度 + /// Width int? width; - /// 长度 + /// Height int? height; - /// 图片URL地址 + /// Image URL String? url; PictureInfo( @@ -436,21 +438,21 @@ class PictureInfo { } } -/// 语音消息内容 +/// Voice message content class SoundElem { - /// id + /// ID String? uuid; - /// 原路径 + /// Original path String? soundPath; - /// url地址 + /// URL address String? sourceUrl; - /// 大小 + /// Size int? dataSize; - /// 时间s + /// Duration in seconds int? duration; SoundElem( @@ -479,42 +481,42 @@ class SoundElem { } } -/// 视频消息内容 +/// Video message content class VideoElem { - /// 视频路径 + /// Video path String? videoPath; - /// uuid + /// UUID String? videoUUID; - /// 视频的url地址 + /// URL address of the video String? videoUrl; - /// mime类型 + /// MIME type String? videoType; - /// 大小 + /// Size int? videoSize; - /// 时长s + /// Duration in seconds int? duration; - /// 缩率图路径 + /// Snapshot path String? snapshotPath; - /// 缩率图uuid + /// Snapshot UUID String? snapshotUUID; - /// 缩率图大小 + /// Snapshot size int? snapshotSize; - /// 缩率图URL地址 + /// Snapshot URL address String? snapshotUrl; - /// 缩率图宽度 + /// Snapshot width int? snapshotWidth; - /// 缩率图高度 + /// Snapshot height int? snapshotHeight; VideoElem( @@ -564,21 +566,21 @@ class VideoElem { } } -/// 文件消息内容 +/// File message content class FileElem { - /// 文件路径 + /// File path String? filePath; - /// uuid + /// UUID String? uuid; - /// 文件URL地址 + /// File URL address String? sourceUrl; - /// 文件名 + /// File name String? fileName; - /// 文件大小 + /// File size int? fileSize; FileElem( @@ -603,21 +605,21 @@ class FileElem { } } -/// @消息内容 +/// @ Message Content class AtTextElem { - /// 消息内容 + /// Message content String? text; - /// 被@的用户ID列表 + /// List of user IDs mentioned in the message List? atUserList; - /// 是否包含自己 + /// Whether it includes a mention of oneself bool? isAtSelf; - /// 被@的用户ID跟昵称关系列表,用于将消息内容里的用户id替换为昵称显示 + /// List of user IDs and their nicknames mentioned in the message, used to replace user IDs with nicknames in the message content List? atUsersInfo; - /// 被回复的消息体,回复别人并@了人 + /// Message that is being replied to, when replying to someone and mentioning others Message? quoteMessage; AtTextElem({ @@ -655,15 +657,15 @@ class AtTextElem { } } -/// 位置消息内日 +/// Location Message class LocationElem { - /// 位置描述 + /// Location description String? description; - /// 经度 + /// Longitude double? longitude; - /// 纬度 + /// Latitude double? latitude; LocationElem({this.description, this.longitude, this.latitude}); @@ -692,15 +694,15 @@ class LocationElem { } } -/// 自定义消息 +/// Custom Message class CustomElem { - /// 自定义数据 + /// Custom data String? data; - /// 扩展内容 + /// Extended content String? extension; - /// 描述内容 + /// Description String? description; CustomElem({this.data, this.extension, this.description}); @@ -720,12 +722,12 @@ class CustomElem { } } -/// 引用消息(被回复的消息) +/// Quoted Message (Reply to a message) class QuoteElem { - /// 回复内容内容 + /// Reply content String? text; - /// 被回复的消息体 + /// The message being replied to Message? quoteMessage; QuoteElem({this.text, this.quoteMessage}); @@ -745,15 +747,15 @@ class QuoteElem { } } -/// 合并消息体 +/// Merged Message Body class MergeElem { - /// 标题 + /// Title String? title; - /// 摘要 + /// Summary List? abstractList; - /// 具体选择合并的消息列表 + /// List of specific messages to merge List? multiMessage; MergeElem({this.title, this.abstractList, this.multiMessage}); @@ -779,12 +781,12 @@ class MergeElem { } } -/// 通知 +/// Notification class NotificationElem { - /// 详情 + /// Details String? detail; - /// 提示 + /// Default tips String? defaultTips; NotificationElem({this.detail, this.defaultTips}); @@ -802,12 +804,12 @@ class NotificationElem { } } -/// 表情 +/// Emoticon class FaceElem { - /// 位置表情,用户端对端自定义内嵌的表情包 + /// Position emoticon, user-defined embedded emoticon for peer-to-peer communication int? index; - /// 其他表情,如URL表情直接返回url + /// Other emoticons, such as URL emoticons directly returning the URL String? data; FaceElem({this.index, this.data}); @@ -825,22 +827,22 @@ class FaceElem { } } -/// 附加信息 +/// Additional Information class AttachedInfoElem { - /// 群消息已读信息 + /// Group message read information GroupHasReadInfo? groupHasReadInfo; - /// 是否为私聊消息(阅后即焚消息),单聊有效 + /// Whether it is a private chat message (burn after reading message), valid for one-on-one chats bool? isPrivateChat; - /// 已读时间 + /// Read time int? hasReadTime; - /// 阅读时长 s - /// 即从hasReadTime时间算起,超过了burnDuration秒触发销毁 + /// Reading duration in seconds + /// That is, it triggers destruction after burnDuration seconds from the hasReadTime time int? burnDuration; - /// 离线不发送推送 + /// Do not send offline push notifications bool? notSenderNotificationPush; AttachedInfoElem({ @@ -981,15 +983,15 @@ class MessageEntity { } } -/// 群消息已读信息 +/// Group message read information class GroupHasReadInfo { - /// 已读的用户id列表 + /// List of user IDs that have read the message List? hasReadUserIDList; - /// 已读总数 + /// Total number of messages read int? hasReadCount; - /// 发送此条消息时的群人数 + /// Number of group members when this message was sent int? groupMemberCount; GroupHasReadInfo.fromJson(Map json) { @@ -1011,27 +1013,27 @@ class GroupHasReadInfo { } } -/// 消息已读回执信息 +/// Message read receipt information class ReadReceiptInfo { - /// 发送者id + /// Sender's ID String? userID; - /// 群id + /// Group ID String? groupID; - /// 已读消息的clientMsgID集合 + /// List of clientMsgIDs for read messages List? msgIDList; - /// 读时间 + /// Read time int? readTime; - /// 消息来源 + /// Message source int? msgFrom; - /// 消息类型[MessageType] + /// Message type [MessageType] int? contentType; - /// 会话类型[ConversationType] + /// Conversation type [ConversationType] int? sessionType; ReadReceiptInfo( @@ -1067,21 +1069,21 @@ class ReadReceiptInfo { } } -/// 离线推送信息 +/// Offline push information class OfflinePushInfo { - /// 通知标题 + /// Notification title String? title; - /// 通知描述 + /// Notification description String? desc; - /// 扩展内容 + /// Extended content String? ex; - /// 仅ios有效 + /// iOS-specific String? iOSPushSound; - /// 仅ios有效 + /// iOS-specific bool? iOSBadgeCount; OfflinePushInfo( @@ -1106,12 +1108,12 @@ class OfflinePushInfo { } } -/// @消息用户id跟昵称关系对象 +/// @ message user ID and nickname relationship object class AtUserInfo { - /// 被@的用户id + /// User ID who was @ mentioned String? atUserID; - /// 被@的用户昵称 + /// User nickname who was @ mentioned String? groupNickname; AtUserInfo({this.atUserID, this.groupNickname}); @@ -1129,33 +1131,33 @@ class AtUserInfo { } } -/// 消息撤回具体信息 +/// Message revocation details class RevokedInfo { - /// 撤回者ID + /// Revoker's ID String? revokerID; - /// 撤回者群角色 [GroupRoleLevel] + /// Revoker's group role [GroupRoleLevel] int? revokerRole; - /// 撤回者昵称 + /// Revoker's nickname String? revokerNickname; - /// 消息id + /// Message ID String? clientMsgID; - /// 撤回时间 + /// Revocation time int? revokeTime; - /// 消息发送时间 + /// Message sending time int? sourceMessageSendTime; - /// 消息发送者 + /// Message sender String? sourceMessageSendID; - /// 消息发送者昵称 + /// Message sender's nickname String? sourceMessageSenderNickname; - /// 会话类型 [ConversationType] + /// Conversation type [ConversationType] int? sessionType; RevokedInfo({ @@ -1269,31 +1271,6 @@ class RichMessageInfo { } } -///////////////////// 消息修改相关///////////////////// -//////////////////////////////////////////////////// - -class KeyValue { - String? typeKey; - String? value; - int? latestUpdateTime; - - KeyValue({this.typeKey, this.value, this.latestUpdateTime}); - - KeyValue.fromJson(Map json) { - typeKey = json['typeKey']; - value = json['value']; - latestUpdateTime = json['latestUpdateTime']; - } - - Map toJson() { - final data = Map(); - data['typeKey'] = this.typeKey; - data['value'] = this.value; - data['latestUpdateTime'] = this.latestUpdateTime; - return data; - } -} - class UserExInfo { String? userID; String? ex; @@ -1312,129 +1289,3 @@ class UserExInfo { return data; } } - -class SingleTypeKeyInfoSum { - String? typeKey; - int? counter; - List? infoList; - bool? isContainSelf; - - SingleTypeKeyInfoSum({ - this.typeKey, - this.counter, - this.infoList, - this.isContainSelf, - }); - - SingleTypeKeyInfoSum.fromJson(Map json) { - typeKey = json['typeKey']; - counter = json['counter']; - infoList = json['infoList'] == null - ? null - : (json['infoList'] as List) - .map((e) => UserExInfo.fromJson(e)) - .toList(); - isContainSelf = json['isContainSelf']; - } - - Map toJson() { - final data = Map(); - data['typeKey'] = this.typeKey; - data['counter'] = this.counter; - data['infoList'] = this.infoList?.map((e) => e.toJson()).toList(); - data['isContainSelf'] = this.isContainSelf; - return data; - } -} - -class MessageKv { - String? clientMsgID; - List? changedKvList; - - MessageKv({this.clientMsgID, this.changedKvList}); - - MessageKv.fromJson(Map json) { - clientMsgID = json['clientMsgID']; - changedKvList = json['changedKvList'] == null - ? null - : (json['changedKvList'] as List) - .map((e) => SingleTypeKeyInfoSum.fromJson(e)) - .toList(); - } - - Map toJson() { - final data = Map(); - data['clientMsgID'] = this.clientMsgID; - data['changedKvList'] = this.changedKvList?.map((e) => e.toJson()).toList(); - return data; - } -} - -class TypeKeySetResult { - int? errCode; - String? errMsg; - String? typeKey; - int? latestUpdateTime; - String? value; - - TypeKeySetResult( - {this.errCode, - this.errMsg, - this.typeKey, - this.latestUpdateTime, - this.value}); - - TypeKeySetResult.fromJson(Map json) { - errCode = json['errCode']; - errMsg = json['errMsg']; - typeKey = json['typeKey']; - latestUpdateTime = json['latestUpdateTime']; - value = json['value']; - } - - Map toJson() { - final Map data = new Map(); - data['errCode'] = this.errCode; - data['errMsg'] = this.errMsg; - data['typeKey'] = this.typeKey; - data['latestUpdateTime'] = this.latestUpdateTime; - data['value'] = this.value; - return data; - } -} - -class MessageTypeKeyMapping { - int? errCode; - String? errMsg; - Map? reactionExtensionList; - String? clientMsgID; - - MessageTypeKeyMapping( - {this.errCode, - this.errMsg, - this.reactionExtensionList, - this.clientMsgID}); - - MessageTypeKeyMapping.fromJson(Map json) { - errCode = json['errCode']; - errMsg = json['errMsg']; - reactionExtensionList = json['reactionExtensionList'] != null - ? (json['reactionExtensionList'] as Map) - .map((key, value) => MapEntry(key, KeyValue.fromJson(value))) - : null; - clientMsgID = json['clientMsgID']; - } - - Map toJson() { - final Map data = new Map(); - data['errCode'] = this.errCode; - data['errMsg'] = this.errMsg; - if (this.reactionExtensionList != null) { - data['reactionExtensionList'] = this - .reactionExtensionList! - .map((key, value) => MapEntry(key, value.toJson())); - } - data['clientMsgID'] = this.clientMsgID; - return data; - } -} diff --git a/lib/src/models/notification_info.dart b/lib/src/models/notification_info.dart index e20d7ed..085d5d8 100644 --- a/lib/src/models/notification_info.dart +++ b/lib/src/models/notification_info.dart @@ -1,38 +1,41 @@ import '../../flutter_openim_sdk.dart'; -/// oa 通知 +/// OA notification class OANotification { - /// 标题 + /// Title String? notificationName; - /// 头像 + /// Avatar String? notificationFaceURL; - /// 类型 + /// Type int? notificationType; - /// 文本内容 + /// Text content String? text; - /// 跳转链接 + /// Redirect link String? externalUrl; - /// 0:纯文字通知 1:文字+图片通知 2:文字+视频通知 3:文字+文件通知 + /// 0: Text-only notification + /// 1: Text + Image notification + /// 2: Text + Video notification + /// 3: Text + File notification int? mixType; - /// 图片信息 + /// Image information PictureElem? pictureElem; - /// 语音信息 + /// Sound information SoundElem? soundElem; - /// 视频信息 + /// Video information VideoElem? videoElem; - /// 文件信息 + /// File information FileElem? fileElem; - /// 扩展字段 + /// Additional field String? ex; OANotification( diff --git a/lib/src/models/search_info.dart b/lib/src/models/search_info.dart index b412a0b..acb2091 100644 --- a/lib/src/models/search_info.dart +++ b/lib/src/models/search_info.dart @@ -1,10 +1,10 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; class SearchResult { - /// 获取到的总的消息数量 + /// Total number of messages obtained int? totalCount; - /// 搜索到的具体内容 + /// Specific search results List? searchResultItems; List? findResultItems; @@ -43,22 +43,22 @@ class SearchResult { } class SearchResultItems { - /// 会话ID + /// Conversation ID String? conversationID; - /// 会话类型1单聊,2群聊,3,超级大群,4通知会话 + /// Conversation type: 1 for single chat, 2 for group chat, 3 for supergroup, 4 for notification conversation int? conversationType; - /// 显示名 + /// Display name String? showName; - /// 头像 + /// Profile picture String? faceURL; - /// 搜索到的这个会话下的消息数量 + /// Number of messages found in this conversation int? messageCount; - /// [Message]的列表 + /// List of [Message]s List? messageList; SearchResultItems({this.conversationID, this.messageCount, this.messageList}); diff --git a/lib/src/models/user_info.dart b/lib/src/models/user_info.dart index 62330f4..5c0d1fb 100644 --- a/lib/src/models/user_info.dart +++ b/lib/src/models/user_info.dart @@ -1,68 +1,71 @@ -/// Is a friend not in the blacklist -/// 是好友不在黑名单 -/// Not a friend on the blacklist -/// 不是好友在黑名单 -/// Not a friend is not on the blacklist -/// 不是好友不在黑名单 class UserInfo { - /// 用户id + /// User ID String? userID; - /// 用户昵称 + /// User nickname String? nickname; - /// 头像 + /// Profile picture String? faceURL; - /// 性别 + /// Gender int? gender; - /// 手机号 + /// Phone number String? phoneNumber; - /// 出生时间 + /// Date of birth int? birth; - /// 邮箱 + /// Email String? email; - /// 扩展字段 + /// Additional information String? ex; - /// 创建时间 + /// Creation time int? createTime; - /// 备注 + /// Remark String? remark; - /// 全局免打扰 0:正常;1:不接受消息;2:接受在线消息不接受离线消息; + /// Global do not disturb setting: + /// 0: Normal + /// 1: Do not accept messages + /// 2: Accept online messages but not offline messages int? globalRecvMsgOpt; - /// 是允许添加为好友 1:允许,2:否 + /// Allow adding as a friend: + /// 1: Allowed + /// 2: Not allowed int? allowAddFriend; - /// 新消息铃声 1:允许,2:否 + /// New message ringtone: + /// 1: Allowed + /// 2: Not allowed int? allowBeep; - /// 新消息震动 1:允许,2:否 + /// New message vibration: + /// 1: Allowed + /// 2: Not allowed int? allowVibration; - /// 禁止登录 + /// Prohibited from logging in int? forbidden; - /// 用户公开的资料 + /// User's public information PublicUserInfo? publicInfo; - /// 好友才能查看的资料 + /// Information visible only to friends FriendInfo? friendInfo; - /// 黑名单资料 + /// Blacklist information BlacklistInfo? blackInfo; - /// 是否好友关系 + /// Whether there is a friendship relationship bool? isFriendship; - /// 是否黑名单 + /// Whether the user is in the blacklist bool? isBlacklist; UserInfo({ @@ -89,23 +92,17 @@ class UserInfo { this.forbidden, }); - // UserInfo.self(Map json) { - // userID = json['userID']; - // nickname = json['nickname']; - // faceURL = json['faceURL']; - // gender = json['gender']; - // phoneNumber = json['phoneNumber']; - // birth = json['birth']; - // email = json['email']; - // ex = json['ex']; - // createTime = json['createTime']; - // } - UserInfo.fromJson(Map json) { - publicInfo = json['publicInfo'] != null ? PublicUserInfo.fromJson(json['publicInfo']) : null; - friendInfo = json['friendInfo'] != null ? FriendInfo.fromJson(json['friendInfo']) : null; - blackInfo = json['blackInfo'] != null ? BlacklistInfo.fromJson(json['blackInfo']) : null; - // + publicInfo = json['publicInfo'] != null + ? PublicUserInfo.fromJson(json['publicInfo']) + : null; + friendInfo = json['friendInfo'] != null + ? FriendInfo.fromJson(json['friendInfo']) + : null; + blackInfo = json['blackInfo'] != null + ? BlacklistInfo.fromJson(json['blackInfo']) + : null; + isFriendship = friendInfo != null; isBlacklist = blackInfo != null; @@ -152,23 +149,27 @@ class UserInfo { return data; } - // bool get isFriendship => null != friendInfo; - // - // bool get isBlacklist => null != blackInfo; - bool get isMale => gender == 1; - String get _userID => isFriendship! ? friendInfo!.userID! : (isBlacklist! ? blackInfo!.userID! : publicInfo!.userID!); + String get _userID => isFriendship! + ? friendInfo!.userID! + : (isBlacklist! ? blackInfo!.userID! : publicInfo!.userID!); - String? get _nickname => - isFriendship! ? friendInfo?.nickname : (isBlacklist! ? blackInfo?.nickname : publicInfo?.nickname); + String? get _nickname => isFriendship! + ? friendInfo?.nickname + : (isBlacklist! ? blackInfo?.nickname : publicInfo?.nickname); - String? get _faceUrl => - isFriendship! ? friendInfo?.faceURL : (isBlacklist! ? blackInfo?.faceURL : publicInfo?.faceURL); + String? get _faceUrl => isFriendship! + ? friendInfo?.faceURL + : (isBlacklist! ? blackInfo?.faceURL : publicInfo?.faceURL); - int? get _gender => isFriendship! ? friendInfo?.gender : (isBlacklist! ? blackInfo?.gender : publicInfo?.gender); + int? get _gender => isFriendship! + ? friendInfo?.gender + : (isBlacklist! ? blackInfo?.gender : publicInfo?.gender); - String? get _ex => isFriendship! ? friendInfo?.ex : (isBlacklist! ? blackInfo?.ex : publicInfo?.ex); + String? get _ex => isFriendship! + ? friendInfo?.ex + : (isBlacklist! ? blackInfo?.ex : publicInfo?.ex); String? get _phoneNumber => friendInfo?.phoneNumber; @@ -187,30 +188,34 @@ class UserInfo { @override bool operator ==(Object other) => - identical(this, other) || other is UserInfo && runtimeType == other.runtimeType && userID == other.userID; + identical(this, other) || + other is UserInfo && + runtimeType == other.runtimeType && + userID == other.userID; @override int get hashCode => userID.hashCode; } -/// 公开的资料 class PublicUserInfo { - /// 用户id + /// User ID String? userID; - /// 昵称 + /// Nickname String? nickname; - /// 头像 + /// Profile picture String? faceURL; - /// 性别 + /// Gender int? gender; - /// AppOrdinaryUsers = 1 AppAdmin = 2 - int? appMangerLevel; + /// App Manager Level: + /// 1: AppOrdinaryUsers + /// 2: AppAdmin + int? appManagerLevel; - /// 扩展信息 + /// Additional information String? ex; PublicUserInfo({ @@ -218,7 +223,7 @@ class PublicUserInfo { this.nickname, this.faceURL, this.gender, - this.appMangerLevel, + this.appManagerLevel, this.ex, }); @@ -227,7 +232,7 @@ class PublicUserInfo { nickname = json['nickname']; faceURL = json['faceURL']; gender = json['gender']; - appMangerLevel = json['appMangerLevel']; + appManagerLevel = json['appManagerLevel']; ex = json['ex']; } @@ -237,48 +242,47 @@ class PublicUserInfo { data['nickname'] = this.nickname; data['faceURL'] = this.faceURL; data['gender'] = this.gender; - data['appMangerLevel'] = this.appMangerLevel; + data['appMangerLevel'] = this.appManagerLevel; data['ex'] = this.ex; return data; } } -/// 好友信息 class FriendInfo { - /// 用户id + /// User ID String? userID; - /// 昵称 + /// Nickname String? nickname; - /// 头像 + /// Profile picture String? faceURL; - /// 性别 + /// Gender int? gender; - /// 手机号 + /// Phone number String? phoneNumber; - /// 出生日期 + /// Date of birth int? birth; - /// 邮箱 + /// Email String? email; - /// 备注 + /// Remark String? remark; - /// 扩展字段 + /// Additional information String? ex; - /// 创建时间 + /// Creation time int? createTime; - /// 添加方式 + /// Add source int? addSource; - /// 操作者id + /// Operator User ID String? operatorUserID; FriendInfo({ @@ -338,30 +342,29 @@ class FriendInfo { } } -/// 黑名单信息 class BlacklistInfo { - /// 用户id + /// User ID String? userID; - /// 昵称 + /// Nickname String? nickname; - /// 头像 + /// Profile picture String? faceURL; - /// 性别 + /// Gender int? gender; - /// 创建时间 + /// Creation time int? createTime; - /// 添加方式 + /// Add source int? addSource; - /// 操作者 + /// Operator User ID String? operatorUserID; - /// 扩展信息 + /// Additional information String? ex; BlacklistInfo({ @@ -400,12 +403,11 @@ class BlacklistInfo { } } -/// 关系 class FriendshipInfo { - /// 用户id + /// User ID String? userID; - /// 1表示好友(并且不是黑名单) + /// 1 represents a friend (and not in the blacklist) int? result; FriendshipInfo({this.userID, this.result}); @@ -423,51 +425,50 @@ class FriendshipInfo { } } -/// 好友申请信息 class FriendApplicationInfo { - /// 发起者用户id + /// Initiator user ID String? fromUserID; - /// 发起者用户昵称 + /// Initiator user nickname String? fromNickname; - /// 发起者用户头像 + /// Initiator user profile picture String? fromFaceURL; - /// 发起者性别 + /// Initiator user gender int? fromGender; - /// 接收者用户id + /// Recipient user ID String? toUserID; - /// 接收者用户昵称 + /// Recipient user nickname String? toNickname; - /// 接收者头像 + /// Recipient user profile picture String? toFaceURL; - /// 接收者性别 + /// Recipient user gender int? toGender; - /// 处理结果 + /// Handling result int? handleResult; - /// 请求消息 + /// Request message String? reqMsg; - /// 创建时间 + /// Creation time int? createTime; - /// 处理者id + /// Handler user ID String? handlerUserID; - /// 处理备注 + /// Handling remark String? handleMsg; - /// 处理时间 + /// Handling time int? handleTime; - /// 扩展字段 + /// Additional information String? ex; FriendApplicationInfo( @@ -525,24 +526,24 @@ class FriendApplicationInfo { return data; } - /// 等待处理 + /// Waiting to be processed bool get isWaitingHandle => handleResult == 0; - /// 已同意 + /// Already agreed bool get isAgreed => handleResult == 1; - /// 已拒绝 + /// Already rejected bool get isRejected => handleResult == -1; } class UserStatusInfo { - /// 用户id + /// User ID String? userID; - /// 状态 + /// Status int? status; - /// 平台ID + /// Platform IDs List? platformIDs; UserStatusInfo({ @@ -554,7 +555,9 @@ class UserStatusInfo { UserStatusInfo.fromJson(Map json) { userID = json['userID']; status = json['status']; - platformIDs = json["platformIDs"] == null ? [] : List.from(json["platformIDs"].map((x) => x)); + platformIDs = json["platformIDs"] == null + ? [] + : List.from(json["platformIDs"].map((x) => x)); } Map toJson() { diff --git a/pubspec.lock b/pubspec.lock index dd4cb56..4ac96db 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -6,7 +6,7 @@ packages: description: name: async sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.10.0" boolean_selector: @@ -14,7 +14,7 @@ packages: description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" characters: @@ -22,7 +22,7 @@ packages: description: name: characters sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.1" clock: @@ -30,7 +30,7 @@ packages: description: name: clock sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.1" collection: @@ -38,7 +38,7 @@ packages: description: name: collection sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.17.0" fake_async: @@ -46,7 +46,7 @@ packages: description: name: fake_async sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.1" flutter: @@ -64,7 +64,7 @@ packages: description: name: js sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.6.5" matcher: @@ -72,7 +72,7 @@ packages: description: name: matcher sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.12.13" material_color_utilities: @@ -80,7 +80,7 @@ packages: description: name: material_color_utilities sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.0" meta: @@ -88,7 +88,7 @@ packages: description: name: meta sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.8.0" path: @@ -96,7 +96,7 @@ packages: description: name: path sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.8.2" sky_engine: @@ -109,7 +109,7 @@ packages: description: name: source_span sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.9.1" stack_trace: @@ -117,7 +117,7 @@ packages: description: name: stack_trace sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.11.0" stream_channel: @@ -125,7 +125,7 @@ packages: description: name: stream_channel sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" string_scanner: @@ -133,7 +133,7 @@ packages: description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.0" term_glyph: @@ -141,7 +141,7 @@ packages: description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: @@ -149,7 +149,7 @@ packages: description: name: test_api sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.4.16" vector_math: @@ -157,7 +157,7 @@ packages: description: name: vector_math sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.4" sdks: