new_version1
This commit is contained in:
@@ -7,17 +7,19 @@ export 'src/enum/listener_type.dart';
|
||||
export 'src/enum/message_status.dart';
|
||||
export 'src/enum/message_type.dart';
|
||||
export 'src/listener/advanced_msg_listener.dart';
|
||||
export 'src/listener/connect_listener.dart';
|
||||
export 'src/listener/conversation_listener.dart';
|
||||
export 'src/listener/friendship_listener.dart';
|
||||
export 'src/listener/group_listener.dart';
|
||||
export 'src/listener/impl/advanced_msg_listener.dart';
|
||||
export 'src/listener/impl/connect_listener.dart';
|
||||
export 'src/listener/impl/conversation_listener.dart';
|
||||
export 'src/listener/impl/friendship_listener.dart';
|
||||
export 'src/listener/impl/group_listener.dart';
|
||||
export 'src/listener/impl/init_sdk_listener.dart';
|
||||
export 'src/listener/impl/msg_send_progress_listener.dart';
|
||||
export 'src/listener/init_sdk_listener.dart';
|
||||
export 'src/listener/impl/user_listener.dart';
|
||||
export 'src/listener/msg_send_progress_listener.dart';
|
||||
export 'src/listener/user_listener.dart';
|
||||
export 'src/manager/im_conversation_manager.dart';
|
||||
export 'src/manager/im_friendship_manager.dart';
|
||||
export 'src/manager/im_group_manager.dart';
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
class ListenerType {
|
||||
static const simpleMsgListener = 'simpleMsgListener';
|
||||
static const initSDKListener = 'initSDKListener';
|
||||
static const groupListener = 'groupListener';
|
||||
static const advancedMsgListener = 'advancedMsgListener';
|
||||
static const conversationListener = 'conversationListener';
|
||||
static const friendListener = 'friendListener';
|
||||
static const signalingListener = 'signalingListener';
|
||||
static const msgSendProgressListener = "msgSendProgressListener";
|
||||
static final simpleMsgListener = 'simpleMsgListener';
|
||||
static final connectListener = 'connectListener';
|
||||
static final userListener = 'userListener';
|
||||
static final groupListener = 'groupListener';
|
||||
static final advancedMsgListener = 'advancedMsgListener';
|
||||
static final conversationListener = 'conversationListener';
|
||||
static final friendListener = 'friendListener';
|
||||
static final signalingListener = 'signalingListener';
|
||||
static final msgSendProgressListener = "msgSendProgressListener";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
abstract class InitSDKListener {
|
||||
abstract class ConnectListener {
|
||||
/// SDK is connecting to the server
|
||||
void connecting();
|
||||
|
||||
@@ -17,7 +15,4 @@ abstract class InitSDKListener {
|
||||
/// Ticket expired when online.
|
||||
/// At this time, you need to generate a new userSig and call IMManager's login() function to log in again
|
||||
void userSigExpired();
|
||||
|
||||
/// The information of the logged-in user has been updated
|
||||
void selfInfoUpdated(UserInfo info);
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
abstract class FriendshipListener {
|
||||
void blackListAdd(UserInfo u);
|
||||
void friendApplicationAdded(FriendApplicationInfo u);
|
||||
|
||||
void blackListDeleted(UserInfo u);
|
||||
void friendApplicationDeleted(FriendApplicationInfo u);
|
||||
|
||||
void friendApplicationListAccept(UserInfo u);
|
||||
void friendApplicationAccepted(FriendApplicationInfo u);
|
||||
|
||||
void friendApplicationListAdded(UserInfo u);
|
||||
void friendApplicationRejected(FriendApplicationInfo u);
|
||||
|
||||
void friendApplicationListDeleted(UserInfo u);
|
||||
void friendAdded(FriendInfo u);
|
||||
|
||||
void friendApplicationListReject(UserInfo u);
|
||||
void friendDeleted(FriendInfo u);
|
||||
|
||||
void friendInfoChanged(UserInfo u);
|
||||
void friendInfoChanged(FriendInfo u);
|
||||
|
||||
void friendListAdded(UserInfo u);
|
||||
void blacklistAdded(BlacklistInfo u);
|
||||
|
||||
void friendListDeleted(UserInfo u);
|
||||
void blacklistDeleted(BlacklistInfo u);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
abstract class GroupListener {
|
||||
void memberEnter(String groupId, List<GroupMembersInfo> list);
|
||||
void joinedGroupAdded(GroupInfo info);
|
||||
|
||||
void memberLeave(String groupId, GroupMembersInfo info);
|
||||
void joinedGroupDeleted(GroupInfo info);
|
||||
|
||||
void memberInvited(
|
||||
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list);
|
||||
void groupMemberAdded(GroupMembersInfo info);
|
||||
|
||||
void memberKicked(
|
||||
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list);
|
||||
void groupMemberDeleted(GroupMembersInfo info);
|
||||
|
||||
void groupCreated(String groupId);
|
||||
void receiveJoinGroupApplicationAdded(GroupApplicationInfo info);
|
||||
|
||||
void groupInfoChanged(String groupId, GroupInfo info);
|
||||
void receiveJoinGroupApplicationDeleted(GroupApplicationInfo info);
|
||||
|
||||
void receiveJoinApplication(
|
||||
String groupId, GroupMembersInfo info, String opReason);
|
||||
void groupApplicationAdded(GroupApplicationInfo info);
|
||||
|
||||
void applicationProcessed(String groupId, GroupMembersInfo opUser,
|
||||
int agreeOrReject, String opReason);
|
||||
void groupApplicationDeleted(GroupApplicationInfo info);
|
||||
|
||||
void groupInfoChanged(GroupInfo info);
|
||||
|
||||
void groupMemberInfoChanged(GroupMembersInfo info);
|
||||
|
||||
void groupApplicationAccepted(GroupApplicationInfo info);
|
||||
|
||||
void groupApplicationRejected(GroupApplicationInfo info);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_openim_sdk/src/listener/connect_listener.dart';
|
||||
|
||||
class OnInitSDKListener extends InitSDKListener {
|
||||
class OnConnectListener extends ConnectListener {
|
||||
Function(int? code, String? errorMsg)? onConnectFailed;
|
||||
Function()? onConnectSuccess;
|
||||
Function()? onConnecting;
|
||||
Function()? onKickedOffline;
|
||||
Function(UserInfo info)? onSelfInfoUpdated;
|
||||
Function()? onUserSigExpired;
|
||||
|
||||
OnInitSDKListener({
|
||||
OnConnectListener({
|
||||
this.onConnectFailed,
|
||||
this.onConnectSuccess,
|
||||
this.onConnecting,
|
||||
this.onKickedOffline,
|
||||
this.onSelfInfoUpdated,
|
||||
this.onUserSigExpired,
|
||||
});
|
||||
|
||||
@@ -37,11 +36,6 @@ class OnInitSDKListener extends InitSDKListener {
|
||||
if (null != onKickedOffline) onKickedOffline!();
|
||||
}
|
||||
|
||||
@override
|
||||
void selfInfoUpdated(UserInfo info) {
|
||||
if (null != onSelfInfoUpdated) onSelfInfoUpdated!(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void userSigExpired() {
|
||||
if (null != onUserSigExpired) onUserSigExpired!();
|
||||
@@ -1,73 +1,93 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
/// 申请添加好友:
|
||||
/// 主动申请者收到 OnFriendApplicationAdded
|
||||
/// 被添加者收到 OnFriendApplicationAdded
|
||||
///
|
||||
/// 同意好友申请:
|
||||
/// 操作者收到 OnFriendApplicationAccepted OnFriendAdded
|
||||
/// 申请者收到 OnFriendApplicationAccepted OnFriendAdded
|
||||
///
|
||||
/// 好友拒绝申请:
|
||||
/// 操作者收到 OnFriendApplicationRejected
|
||||
/// 申请者收到 OnFriendApplicationRejected
|
||||
///
|
||||
/// 删除好友:
|
||||
/// 操作者收到 OnFriendDeleted
|
||||
///
|
||||
/// 修改备注:
|
||||
/// 操作者收到 OnFriendInfoChanged
|
||||
///
|
||||
/// 添加黑名单:
|
||||
/// 操作者收到 OnBlacklistAdded;
|
||||
///
|
||||
/// 移除黑名单:
|
||||
/// 操作者收到 OnBlacklistDeleted
|
||||
class OnFriendshipListener extends FriendshipListener {
|
||||
Function(UserInfo u)? onBlackListAdd;
|
||||
Function(UserInfo u)? onBlackListDeleted;
|
||||
Function(UserInfo u)? onFriendApplicationListAccept;
|
||||
Function(UserInfo u)? onFriendApplicationListAdded;
|
||||
Function(UserInfo u)? onFriendApplicationListDeleted;
|
||||
Function(UserInfo u)? onFriendApplicationListReject;
|
||||
Function(UserInfo u)? onFriendInfoChanged;
|
||||
Function(UserInfo u)? onFriendListAdded;
|
||||
Function(UserInfo u)? onFriendListDeleted;
|
||||
Function(FriendApplicationInfo i)? onFriendApplicationAdded;
|
||||
Function(FriendApplicationInfo i)? onFriendApplicationDeleted;
|
||||
Function(FriendApplicationInfo i)? onFriendApplicationAccepted;
|
||||
Function(FriendApplicationInfo i)? onFriendApplicationRejected;
|
||||
Function(FriendInfo i)? onFriendAdded;
|
||||
Function(FriendInfo i)? onFriendDeleted;
|
||||
Function(FriendInfo i)? onFriendInfoChanged;
|
||||
Function(BlacklistInfo i)? onBlacklistAdded;
|
||||
Function(BlacklistInfo i)? onBlacklistDeleted;
|
||||
|
||||
OnFriendshipListener({
|
||||
this.onBlackListAdd,
|
||||
this.onBlackListDeleted,
|
||||
this.onFriendApplicationListAccept,
|
||||
this.onFriendApplicationListAdded,
|
||||
this.onFriendApplicationListDeleted,
|
||||
this.onFriendApplicationListReject,
|
||||
this.onBlacklistAdded,
|
||||
this.onBlacklistDeleted,
|
||||
this.onFriendAdded,
|
||||
this.onFriendApplicationAccepted,
|
||||
this.onFriendApplicationAdded,
|
||||
this.onFriendApplicationDeleted,
|
||||
this.onFriendApplicationRejected,
|
||||
this.onFriendDeleted,
|
||||
this.onFriendInfoChanged,
|
||||
this.onFriendListAdded,
|
||||
this.onFriendListDeleted,
|
||||
});
|
||||
|
||||
@override
|
||||
void blackListAdd(UserInfo u) {
|
||||
if (null != onBlackListAdd) onBlackListAdd!(u);
|
||||
void blacklistAdded(BlacklistInfo u) {
|
||||
onBlacklistAdded?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void blackListDeleted(UserInfo u) {
|
||||
if (null != onBlackListDeleted) onBlackListDeleted!(u);
|
||||
void blacklistDeleted(BlacklistInfo u) {
|
||||
onBlacklistDeleted?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void friendApplicationListAccept(UserInfo u) {
|
||||
if (null != onFriendApplicationListAccept)
|
||||
onFriendApplicationListAccept!(u);
|
||||
void friendAdded(FriendInfo u) {
|
||||
onFriendAdded?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void friendApplicationListAdded(UserInfo u) {
|
||||
if (null != onFriendApplicationListAdded) onFriendApplicationListAdded!(u);
|
||||
void friendApplicationAccepted(FriendApplicationInfo u) {
|
||||
onFriendApplicationAccepted?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void friendApplicationListDeleted(UserInfo u) {
|
||||
if (null != onFriendApplicationListDeleted)
|
||||
onFriendApplicationListDeleted!(u);
|
||||
void friendApplicationAdded(FriendApplicationInfo u) {
|
||||
onFriendApplicationAdded?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void friendApplicationListReject(UserInfo u) {
|
||||
if (null != onFriendApplicationListReject)
|
||||
onFriendApplicationListReject!(u);
|
||||
void friendApplicationDeleted(FriendApplicationInfo u) {
|
||||
onFriendApplicationDeleted?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void friendInfoChanged(UserInfo u) {
|
||||
if (null != onFriendInfoChanged) onFriendInfoChanged!(u);
|
||||
void friendApplicationRejected(FriendApplicationInfo u) {
|
||||
onFriendApplicationRejected?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void friendListAdded(UserInfo u) {
|
||||
if (null != onFriendListAdded) onFriendListAdded!(u);
|
||||
void friendDeleted(FriendInfo u) {
|
||||
onFriendDeleted?.call(u);
|
||||
}
|
||||
|
||||
@override
|
||||
void friendListDeleted(UserInfo u) {
|
||||
if (null != onFriendListDeleted) onFriendListDeleted!(u);
|
||||
void friendInfoChanged(FriendInfo u) {
|
||||
onFriendInfoChanged?.call(u);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +1,121 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
/// 创建群:
|
||||
/// 初始成员收到 OnJoinedGroupAdded
|
||||
///
|
||||
/// 退出群:
|
||||
/// 退出者收到 OnJoinedGroupDeleted
|
||||
/// 群成员收到 OnGroupMemberDeleted
|
||||
///
|
||||
/// 踢出群:
|
||||
/// 被踢者收到 OnJoinedGroupDeleted
|
||||
/// 群成员收到 OnGroupMemberDeleted
|
||||
///
|
||||
/// 邀请进群:
|
||||
/// 被邀请者收到 OnJoinedGroupAdded
|
||||
/// 群成员(不包括被邀请者)收到 OnGroupMemberAdded
|
||||
///
|
||||
/// 申请加群:
|
||||
/// 申请者收到 OnGroupApplicationAdded
|
||||
/// 群主+管理员收到 OnReceiveJoinGroupApplicationAdded
|
||||
///
|
||||
/// 同意进群:
|
||||
/// 申请者收到 OnJoinedGroupAdded OnGroupApplicationAccepted
|
||||
/// 群成员(不包括申请者)收到 OnGroupMemberAdded
|
||||
/// 审批者(群主或者管理员)收到 OnGroupMemberAdded OnGroupApplicationAccepted
|
||||
///
|
||||
/// 拒绝进群:
|
||||
/// 申请者收到 OnGroupApplicationRejected;
|
||||
/// 审批者(群主或者管理员)收到 OnGroupApplicationRejected
|
||||
///
|
||||
/// 修改群资料:
|
||||
/// 群成员收到 OnGroupInfoChanged
|
||||
class OnGroupListener extends GroupListener {
|
||||
Function(String groupId, GroupMembersInfo opUser, int agreeOrReject,
|
||||
String opReason)? onApplicationProcessed;
|
||||
Function(String groupId)? onGroupCreated;
|
||||
Function(String groupId, GroupInfo info)? onGroupInfoChanged;
|
||||
Function(String groupId, List<GroupMembersInfo> list)? onMemberEnter;
|
||||
Function(
|
||||
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list)?
|
||||
onMemberInvited;
|
||||
Function(
|
||||
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list)?
|
||||
onMemberKicked;
|
||||
Function(String groupId, GroupMembersInfo info)? onMemberLeave;
|
||||
Function(String groupId, GroupMembersInfo info, String opReason)?
|
||||
onReceiveJoinApplication;
|
||||
Function(GroupApplicationInfo info)? onGroupApplicationAccepted;
|
||||
Function(GroupApplicationInfo info)? onGroupApplicationAdded;
|
||||
Function(GroupApplicationInfo info)? onGroupApplicationDeleted;
|
||||
Function(GroupApplicationInfo info)? onGroupApplicationRejected;
|
||||
Function(GroupInfo info)? onGroupInfoChanged;
|
||||
Function(GroupMembersInfo info)? onGroupMemberAdded;
|
||||
Function(GroupMembersInfo info)? onGroupMemberDeleted;
|
||||
Function(GroupMembersInfo info)? onGroupMemberInfoChanged;
|
||||
Function(GroupInfo info)? onJoinedGroupAdded;
|
||||
Function(GroupInfo info)? onJoinedGroupDeleted;
|
||||
Function(GroupApplicationInfo info)? onReceiveJoinGroupApplicationAdded;
|
||||
Function(GroupApplicationInfo info)? onReceiveJoinGroupApplicationDeleted;
|
||||
|
||||
OnGroupListener({
|
||||
this.onApplicationProcessed,
|
||||
this.onGroupCreated,
|
||||
this.onGroupApplicationAccepted,
|
||||
this.onGroupApplicationAdded,
|
||||
this.onGroupApplicationDeleted,
|
||||
this.onGroupApplicationRejected,
|
||||
this.onGroupInfoChanged,
|
||||
this.onMemberEnter,
|
||||
this.onMemberInvited,
|
||||
this.onMemberKicked,
|
||||
this.onMemberLeave,
|
||||
this.onReceiveJoinApplication,
|
||||
this.onGroupMemberAdded,
|
||||
this.onGroupMemberDeleted,
|
||||
this.onGroupMemberInfoChanged,
|
||||
this.onJoinedGroupAdded,
|
||||
this.onJoinedGroupDeleted,
|
||||
this.onReceiveJoinGroupApplicationAdded,
|
||||
this.onReceiveJoinGroupApplicationDeleted,
|
||||
});
|
||||
|
||||
@override
|
||||
void applicationProcessed(String groupId, GroupMembersInfo opUser,
|
||||
int agreeOrReject, String opReason) {
|
||||
if (null != onApplicationProcessed)
|
||||
onApplicationProcessed!(groupId, opUser, agreeOrReject, opReason);
|
||||
void groupApplicationAccepted(GroupApplicationInfo info) {
|
||||
onGroupApplicationAccepted?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void groupCreated(String groupId) {
|
||||
if (null != onGroupCreated) onGroupCreated!(groupId);
|
||||
void groupApplicationAdded(GroupApplicationInfo info) {
|
||||
onGroupApplicationAdded?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void groupInfoChanged(String groupId, GroupInfo info) {
|
||||
if (null != onGroupInfoChanged) onGroupInfoChanged!(groupId, info);
|
||||
void groupApplicationDeleted(GroupApplicationInfo info) {
|
||||
onGroupApplicationDeleted?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void memberEnter(String groupId, List<GroupMembersInfo> list) {
|
||||
if (null != onMemberEnter) onMemberEnter!(groupId, list);
|
||||
void groupApplicationRejected(GroupApplicationInfo info) {
|
||||
onGroupApplicationRejected?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void memberInvited(
|
||||
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list) {
|
||||
if (null != onMemberInvited) onMemberInvited!(groupId, opUser, list);
|
||||
void groupInfoChanged(GroupInfo info) {
|
||||
onGroupInfoChanged?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void memberKicked(
|
||||
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list) {
|
||||
if (null != onMemberKicked) onMemberKicked!(groupId, opUser, list);
|
||||
void groupMemberAdded(GroupMembersInfo info) {
|
||||
onGroupMemberAdded?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void memberLeave(String groupId, GroupMembersInfo info) {
|
||||
if (null != onMemberLeave) onMemberLeave!(groupId, info);
|
||||
void groupMemberDeleted(GroupMembersInfo info) {
|
||||
onGroupMemberDeleted?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void receiveJoinApplication(
|
||||
String groupId, GroupMembersInfo info, String opReason) {
|
||||
if (null != onReceiveJoinApplication)
|
||||
onReceiveJoinApplication!(groupId, info, opReason);
|
||||
void groupMemberInfoChanged(GroupMembersInfo info) {
|
||||
onGroupMemberInfoChanged?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void joinedGroupAdded(GroupInfo info) {
|
||||
onJoinedGroupAdded?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void joinedGroupDeleted(GroupInfo info) {
|
||||
onJoinedGroupDeleted?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void receiveJoinGroupApplicationAdded(GroupApplicationInfo info) {
|
||||
onReceiveJoinGroupApplicationAdded?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void receiveJoinGroupApplicationDeleted(GroupApplicationInfo info) {
|
||||
onReceiveJoinGroupApplicationDeleted?.call(info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
class OnMsgSendProgressListener extends MsgSendProgressListener {
|
||||
Function(String msgID, int progress)? onProgress;
|
||||
Function(String clientMsgID, int progress)? onProgress;
|
||||
|
||||
OnMsgSendProgressListener({this.onProgress});
|
||||
|
||||
void progress(String msgID, int progress) {
|
||||
if (null != onProgress) onProgress!(msgID, progress);
|
||||
void progress(String clientMsgID, int progress) {
|
||||
if (null != onProgress) onProgress!(clientMsgID, progress);
|
||||
}
|
||||
}
|
||||
|
||||
12
lib/src/listener/impl/user_listener.dart
Normal file
12
lib/src/listener/impl/user_listener.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
class OnUserListener extends UserListener {
|
||||
Function(UserInfo info)? onSelfInfoUpdated;
|
||||
|
||||
OnUserListener({this.onSelfInfoUpdated});
|
||||
|
||||
@override
|
||||
void selfInfoUpdated(UserInfo info) {
|
||||
onSelfInfoUpdated?.call(info);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
abstract class MsgSendProgressListener {
|
||||
void progress(String msgID, int progress);
|
||||
void progress(String clientMsgID, int progress);
|
||||
}
|
||||
|
||||
6
lib/src/listener/user_listener.dart
Normal file
6
lib/src/listener/user_listener.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
abstract class UserListener {
|
||||
/// The information of the logged-in user has been updated
|
||||
void selfInfoUpdated(UserInfo info);
|
||||
}
|
||||
@@ -20,15 +20,22 @@ class ConversationManager {
|
||||
|
||||
/// Get all conversations
|
||||
/// 获取所有会话
|
||||
Future<List<ConversationInfo>> getAllConversationList() => _channel
|
||||
.invokeMethod('getAllConversationList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
Future<List<ConversationInfo>> getAllConversationList(
|
||||
{String? operationID}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getAllConversationList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Paging to get conversation
|
||||
/// 分页获取会话, [offset]下次获取开始index
|
||||
/// 分页获取会话
|
||||
Future<List<ConversationInfo>> getConversationListSplit({
|
||||
int offset = 0,
|
||||
int count = 20,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -36,18 +43,20 @@ class ConversationManager {
|
||||
_buildParam({
|
||||
'offset': offset,
|
||||
'count': count,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Get a single conversation info
|
||||
/// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
/// [sessionType] if it is a single chat, it value is 1. if it is a group chat, it value is 2
|
||||
/// 获取单个会话
|
||||
/// [sourceID]如果是单聊值传用户id,如果是群聊值传组id
|
||||
/// [sessionType]如果是单聊值传1,如果是群聊值传2
|
||||
Future<ConversationInfo> getSingleConversation({
|
||||
/// Get a conversation, if it doesn't exist it will be created automatically
|
||||
/// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
/// [sessionType] if it is a single chat, it value is 1. if it is a group chat, it value is 2
|
||||
/// 获取一个会话,如果不存在会自动创建
|
||||
/// [sourceID] 如果是单聊值传用户ID,如果是群聊值传组ID
|
||||
/// [sessionType] 如果是单聊值传1,如果是群聊值传2
|
||||
Future<ConversationInfo> getOneConversation({
|
||||
required String sourceID,
|
||||
required int sessionType,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -55,6 +64,7 @@ class ConversationManager {
|
||||
_buildParam({
|
||||
"sourceID": sourceID,
|
||||
"sessionType": sessionType,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -62,12 +72,14 @@ class ConversationManager {
|
||||
/// 获取多个会话
|
||||
Future<List<ConversationInfo>> getMultipleConversation({
|
||||
required List<String> conversationIDList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getMultipleConversation',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
@@ -75,12 +87,14 @@ class ConversationManager {
|
||||
/// 删除会话
|
||||
Future deleteConversation({
|
||||
required String conversationID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'deleteConversation',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
|
||||
@@ -89,6 +103,7 @@ class ConversationManager {
|
||||
Future setConversationDraft({
|
||||
required String conversationID,
|
||||
required String draftText,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -96,6 +111,7 @@ class ConversationManager {
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"draftText": draftText,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
|
||||
@@ -104,6 +120,7 @@ class ConversationManager {
|
||||
Future pinConversation({
|
||||
required String conversationID,
|
||||
required bool isPinned,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -111,33 +128,47 @@ class ConversationManager {
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"isPinned": isPinned,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
|
||||
/// Mark single chat messages as read
|
||||
/// 标记单聊已读
|
||||
Future<dynamic> markSingleMessageHasRead({required String userID}) =>
|
||||
_channel.invokeMethod(
|
||||
'markSingleMessageHasRead', _buildParam({'userID': userID}));
|
||||
// Future<dynamic> markSingleMessageHasRead({required String userID}) =>
|
||||
// _channel.invokeMethod(
|
||||
// 'markSingleMessageHasRead', _buildParam({'userID': userID}));
|
||||
|
||||
/// Mark group chat messages as read
|
||||
/// 标记群聊已读
|
||||
Future<dynamic> markGroupMessageHasRead({required String groupID}) =>
|
||||
Future<dynamic> markGroupMessageHasRead({
|
||||
required String groupID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'markGroupMessageHasRead', _buildParam({'groupID': groupID}));
|
||||
'markGroupMessageHasRead',
|
||||
_buildParam({
|
||||
'groupID': groupID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Get the total number of unread messages
|
||||
/// 获取未读消息总数
|
||||
Future<dynamic> getTotalUnreadMsgCount() =>
|
||||
_channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
|
||||
Future<dynamic> getTotalUnreadMsgCount({
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'getTotalUnreadMsgCount',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Query conversation id
|
||||
/// [sourceID] : if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
/// [sessionType] : if it is a single chat, it value is 1. if it is a group chat, it value is 2
|
||||
/// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
/// [sessionType] if it is a single chat, it value is 1. if it is a group chat, it value is 2
|
||||
/// 查询会话id
|
||||
/// [sourceID]如果是单聊值传用户id,如果是群聊值传组id
|
||||
/// [sessionType]如果是单聊值传1,如果是群聊值传2
|
||||
Future<dynamic> getConversationID({
|
||||
/// [sourceID] 如果是单聊值传用户ID,如果是群聊值传组ID
|
||||
/// [sessionType] 如果是单聊值传1,如果是群聊值传2
|
||||
Future<dynamic> getConversationIDBySessionType({
|
||||
required String sourceID,
|
||||
required int sessionType,
|
||||
}) =>
|
||||
@@ -149,18 +180,20 @@ class ConversationManager {
|
||||
}));
|
||||
|
||||
/// Message Do Not Disturb
|
||||
/// [status] 1: Do not receive messages, 2: Do not notify when messages are received; 0: Normal
|
||||
/// [status] 1: Do not receive messages. 2: Do not notify when messages are received. 0: Normal.
|
||||
/// 消息免打扰设置
|
||||
/// [status] 1:不接受消息;2:接受在线消息不接受离线消息;3:正常
|
||||
Future<dynamic> setConversationRecvMessageOpt({
|
||||
required List<String> conversationIDList,
|
||||
required int status,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"status": status,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Message Do Not Disturb
|
||||
@@ -168,12 +201,14 @@ class ConversationManager {
|
||||
/// 查询免打扰状态
|
||||
Future<List<dynamic>> getConversationRecvMessageOpt({
|
||||
required List<String> conversationIDList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
|
||||
@@ -181,13 +216,13 @@ class ConversationManager {
|
||||
/// 会话列表自定义排序规则
|
||||
List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list
|
||||
..sort((a, b) {
|
||||
if ((a.isPinned == 1 && b.isPinned == 1) ||
|
||||
(a.isPinned != 1 && b.isPinned != 1)) {
|
||||
int aCompare = a.draftTimestamp! > a.latestMsgSendTime!
|
||||
? a.draftTimestamp!
|
||||
if ((a.isPinned == true && b.isPinned == true) ||
|
||||
(a.isPinned != true && b.isPinned != true)) {
|
||||
int aCompare = a.draftTextTime! > a.latestMsgSendTime!
|
||||
? a.draftTextTime!
|
||||
: a.latestMsgSendTime!;
|
||||
int bCompare = b.draftTimestamp! > b.latestMsgSendTime!
|
||||
? b.draftTimestamp!
|
||||
int bCompare = b.draftTextTime! > b.latestMsgSendTime!
|
||||
? b.draftTextTime!
|
||||
: b.latestMsgSendTime!;
|
||||
if (aCompare > bCompare) {
|
||||
return -1;
|
||||
@@ -196,7 +231,7 @@ class ConversationManager {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (a.isPinned == 1 && b.isPinned != 1) {
|
||||
} else if (a.isPinned == true && b.isPinned != true) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
@@ -222,4 +257,8 @@ class ConversationManager {
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,82 +18,189 @@ class FriendshipManager {
|
||||
|
||||
/// Get friend info by user id
|
||||
/// 查询好友信息
|
||||
Future<List<UserInfo>> getFriendsInfo({required List<String> uidList}) =>
|
||||
Future<List<UserInfo>> getFriendsInfo({
|
||||
required List<String> uidList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod('getFriendsInfo', _buildParam({"uidList": uidList}))
|
||||
.then((value) => _toList(value));
|
||||
.invokeMethod(
|
||||
'getFriendsInfo',
|
||||
_buildParam({
|
||||
"uidList": uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
|
||||
/// Send an friend application
|
||||
/// 发送一个好友请求
|
||||
Future<dynamic> addFriend({required String uid, required String reason}) =>
|
||||
Future<dynamic> addFriend({
|
||||
required String uid,
|
||||
String? reason,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'addFriend', _buildParam({"uid": uid, "reqMessage": reason}));
|
||||
'addFriend',
|
||||
_buildParam({
|
||||
"toUserID": uid,
|
||||
"reqMsg": reason,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Get all friend application, sent to you by others
|
||||
/// 获取所有好友申请
|
||||
Future<List<UserInfo>> getFriendApplicationList() => _channel
|
||||
.invokeMethod('getFriendApplicationList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
/// Get someone's request to add me as a friend
|
||||
/// 获取别人加我为好友的申请
|
||||
Future<List<FriendApplicationInfo>> getRecvFriendApplicationList(
|
||||
{String? operationID}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getRecvFriendApplicationList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
_toList(value, (v) => FriendApplicationInfo.fromJson(v.cast())));
|
||||
|
||||
/// Get friend requests from me
|
||||
/// 获取我发出的好友申请
|
||||
Future<List<FriendApplicationInfo>> getSendFriendApplicationList(
|
||||
{String? operationID}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getSendFriendApplicationList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
_toList(value, (v) => FriendApplicationInfo.fromJson(v.cast())));
|
||||
|
||||
/// Find all friends including those who have been added to the blacklist
|
||||
/// 获取好友列表包含已拉入黑名单的好友
|
||||
Future<List<UserInfo>> getFriendList() => _channel
|
||||
.invokeMethod('getFriendList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
Future<List<UserInfo>> getFriendList({String? operationID}) => _channel
|
||||
.invokeMethod(
|
||||
'getFriendList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
|
||||
/// Find all friends including those who have been added to the blacklist
|
||||
/// 获取好友列表
|
||||
Future<List<dynamic>> getFriendListMap() => _channel
|
||||
.invokeMethod('getFriendList', _buildParam({}))
|
||||
Future<List<dynamic>> getFriendListMap({String? operationID}) => _channel
|
||||
.invokeMethod(
|
||||
'getFriendList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toListMap(value));
|
||||
|
||||
/// Modify friend information, only [comment] can be modified
|
||||
/// 设置好友备注
|
||||
Future<dynamic> setFriendInfo(
|
||||
{required String uid, required String comment}) =>
|
||||
Future<dynamic> setFriendRemark({
|
||||
required String uid,
|
||||
required String remark,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setFriendInfo',
|
||||
'setFriendRemark',
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'comment': comment,
|
||||
'toUserID': uid,
|
||||
'remark': remark,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Add friends to blacklist
|
||||
/// 加入黑名单
|
||||
Future<dynamic> addToBlackList({required String uid}) =>
|
||||
_channel.invokeMethod('addToBlackList', _buildParam({"uid": uid}));
|
||||
Future<dynamic> addBlacklist({
|
||||
required String uid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'addBlacklist',
|
||||
_buildParam({
|
||||
"uid": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Find all blacklist
|
||||
/// 获取黑名单列表
|
||||
Future<List<UserInfo>> getBlackList() => _channel
|
||||
.invokeMethod('getBlackList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
Future<List<UserInfo>> getBlacklist({String? operationID}) => _channel
|
||||
.invokeMethod(
|
||||
'getBlacklist',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
|
||||
/// Remove from blacklist
|
||||
/// 从黑名单移除
|
||||
Future<dynamic> deleteFromBlackList({required String uid}) =>
|
||||
_channel.invokeMethod('deleteFromBlackList', _buildParam({"uid": uid}));
|
||||
Future<dynamic> removeBlacklist({
|
||||
required String uid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'removeBlacklist',
|
||||
_buildParam({
|
||||
"uid": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Determine if there is a friendship by userId
|
||||
/// 检查友好关系
|
||||
Future<List<UserInfo>> checkFriend(List<String> uidList) => _channel
|
||||
.invokeMethod('checkFriend', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
Future<List<FriendshipInfo>> checkFriend({
|
||||
required List<String> uidList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'checkFriend',
|
||||
_buildParam({
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
_toList(value, (v) => FriendshipInfo.fromJson(v.cast())));
|
||||
|
||||
/// Dissolve friendship from friend list
|
||||
/// 删除好友
|
||||
Future<dynamic> deleteFromFriendList({required String uid}) =>
|
||||
_channel.invokeMethod('deleteFromFriendList', _buildParam({"uid": uid}));
|
||||
Future<dynamic> deleteFriend({
|
||||
required String uid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'deleteFriend',
|
||||
_buildParam({
|
||||
"uid": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Accept application of be friend
|
||||
/// 接受好友请求
|
||||
Future<dynamic> acceptFriendApplication({required String uid}) => _channel
|
||||
.invokeMethod('acceptFriendApplication', _buildParam({"uid": uid}));
|
||||
Future<dynamic> acceptFriendApplication({
|
||||
required String uid,
|
||||
String? handleMsg,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'acceptFriendApplication',
|
||||
_buildParam({
|
||||
"toUserID": uid,
|
||||
"handleMsg": handleMsg,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Refuse application of be friend
|
||||
/// 拒绝好友请求
|
||||
Future<dynamic> refuseFriendApplication({required String uid}) => _channel
|
||||
.invokeMethod('refuseFriendApplication', _buildParam({"uid": uid}));
|
||||
Future<dynamic> refuseFriendApplication({
|
||||
required String uid,
|
||||
String? handleMsg,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'refuseFriendApplication',
|
||||
_buildParam({
|
||||
"toUserID": uid,
|
||||
"handleMsg": handleMsg,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
///
|
||||
// Future<dynamic> forceSyncFriendApplication() {
|
||||
@@ -115,10 +222,10 @@ class FriendshipManager {
|
||||
return param;
|
||||
}
|
||||
|
||||
static List<UserInfo> _toList(String? value) {
|
||||
static List<T> _toList<T>(String? value, T f(Map map)) {
|
||||
var list = _formatJson(value);
|
||||
if (null == list) return <UserInfo>[];
|
||||
return (list as List).map((e) => UserInfo.fromJson(e)).toList();
|
||||
if (null == list) return <T>[];
|
||||
return (list as List).map((e) => f(e)).toList();
|
||||
}
|
||||
|
||||
static List<dynamic> _toListMap(String? value) {
|
||||
@@ -133,4 +240,8 @@ class FriendshipManager {
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class GroupManager {
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
String? reason,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -31,6 +32,7 @@ class GroupManager {
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
@@ -42,6 +44,7 @@ class GroupManager {
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
String? reason,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -50,6 +53,7 @@ class GroupManager {
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
@@ -60,6 +64,7 @@ class GroupManager {
|
||||
Future<List<GroupMembersInfo>> getGroupMembersInfo({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -67,19 +72,20 @@ class GroupManager {
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Get the list of group members
|
||||
/// [filter] 0: all user, 1: group owner, 2: administrator
|
||||
/// [next] begin index, pull and fill 0 for the first time
|
||||
/// 获取组成员列表
|
||||
Future<GroupMembersList> getGroupMemberList({
|
||||
/// 分页获取组成员列表
|
||||
Future<List<GroupMembersInfo>> getGroupMemberList({
|
||||
required String groupId,
|
||||
int filter = 0,
|
||||
int next = 0,
|
||||
int offset = 0,
|
||||
int count = 0,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -87,16 +93,22 @@ class GroupManager {
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'filter': filter,
|
||||
'next': next,
|
||||
'offset': offset,
|
||||
'count': count,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => GroupMembersList.fromJson(_formatJson(value)));
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Get the list of group members
|
||||
/// 获取组成员列表
|
||||
/// 分页获取组成员列表
|
||||
Future<dynamic> getGroupMemberListMap({
|
||||
required String groupId,
|
||||
int filter = 0,
|
||||
int next = 0,
|
||||
int offset = 0,
|
||||
int count = 0,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -104,49 +116,72 @@ class GroupManager {
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'filter': filter,
|
||||
'next': next,
|
||||
'offset': offset,
|
||||
'count': count,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
|
||||
/// Find all groups you have joined
|
||||
/// 查询已加入的组列表
|
||||
Future<List<GroupInfo>> getJoinedGroupList() => _channel
|
||||
.invokeMethod('getJoinedGroupList', _buildParam({}))
|
||||
Future<List<GroupInfo>> getJoinedGroupList({String? operationID}) => _channel
|
||||
.invokeMethod(
|
||||
'getJoinedGroupList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInfo.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Find all groups you have joined
|
||||
/// 查询已加入的组列表
|
||||
Future<List<dynamic>> getJoinedGroupListMap() => _channel
|
||||
.invokeMethod('getJoinedGroupList', _buildParam({}))
|
||||
Future<List<dynamic>> getJoinedGroupListMap({String? operationID}) => _channel
|
||||
.invokeMethod(
|
||||
'getJoinedGroupList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
|
||||
/// Check if you are a member of the group
|
||||
/// 检查是否已加入组
|
||||
Future<bool> isJoinedGroup({required String gid}) => getJoinedGroupList()
|
||||
.then((list) => list.where((e) => e.groupID == gid).length > 0);
|
||||
Future<bool> isJoinedGroup({
|
||||
required String gid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
getJoinedGroupList(
|
||||
operationID: _checkOperationID(operationID),
|
||||
).then((list) => list.where((e) => e.groupID == gid).length > 0);
|
||||
|
||||
/// Create a group
|
||||
/// 创建一个组
|
||||
Future<dynamic> createGroup({
|
||||
Future<GroupInfo> createGroup({
|
||||
String? groupName,
|
||||
String? notification,
|
||||
String? introduction,
|
||||
String? faceUrl,
|
||||
int? groupType,
|
||||
String? ex,
|
||||
required List<GroupMemberRole> list,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'createGroup',
|
||||
_buildParam({
|
||||
'gInfo': {
|
||||
"groupName": groupName,
|
||||
"notification": notification,
|
||||
"introduction": introduction,
|
||||
"faceUrl": faceUrl,
|
||||
},
|
||||
'memberList': list.map((e) => e.toJson()).toList()
|
||||
}));
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createGroup',
|
||||
_buildParam({
|
||||
'gInfo': {
|
||||
"groupName": groupName,
|
||||
"notification": notification,
|
||||
"introduction": introduction,
|
||||
"faceURL": faceUrl,
|
||||
"groupType": groupType,
|
||||
"ex": ex,
|
||||
},
|
||||
'memberList': list.map((e) => e.toJson()).toList(),
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => GroupInfo.fromJson(_formatJson(value)));
|
||||
|
||||
/// Edit group information
|
||||
/// 编辑组资料
|
||||
@@ -156,26 +191,37 @@ class GroupManager {
|
||||
String? notification,
|
||||
String? introduction,
|
||||
String? faceUrl,
|
||||
String? ex,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setGroupInfo',
|
||||
_buildParam({
|
||||
"gid": groupID,
|
||||
'gInfo': {
|
||||
"groupID": groupID,
|
||||
// "groupID": groupID,
|
||||
"groupName": groupName,
|
||||
"notification": notification,
|
||||
"introduction": introduction,
|
||||
"faceUrl": faceUrl,
|
||||
"faceURL": faceUrl,
|
||||
"ex": ex,
|
||||
},
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Find group information by group id
|
||||
/// 查询组信息
|
||||
Future<List<GroupInfo>> getGroupsInfo({
|
||||
required List<String> gidList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList}))
|
||||
.invokeMethod(
|
||||
'getGroupsInfo',
|
||||
_buildParam({
|
||||
'gidList': gidList,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) {
|
||||
List list = _formatJson(value);
|
||||
return list.map((e) => GroupInfo.fromJson(e)).toList();
|
||||
@@ -186,23 +232,27 @@ class GroupManager {
|
||||
Future<dynamic> joinGroup({
|
||||
required String gid,
|
||||
String? reason,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'joinGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'reason': reason,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Leave group
|
||||
/// 退出组
|
||||
Future<dynamic> quitGroup({
|
||||
required String gid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'quitGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Give group permissions to others
|
||||
@@ -210,44 +260,76 @@ class GroupManager {
|
||||
Future<dynamic> transferGroupOwner({
|
||||
required String gid,
|
||||
required String uid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'transferGroupOwner',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Get the list of applications
|
||||
/// 获取所有进组申请
|
||||
Future<GroupApplicationList> getGroupApplicationList() => _channel
|
||||
.invokeMethod('getGroupApplicationList', _buildParam({}))
|
||||
.then((value) => GroupApplicationList.fromJson(_formatJson(value)));
|
||||
/// As the group owner or administrator, get the list of received group members' applications to join the group.
|
||||
/// 作为群主或者管理员,获取收到的群成员申请进群列表。
|
||||
Future<List<GroupApplicationInfo>> getRecvGroupApplicationList(
|
||||
{String? operationID}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getRecvGroupApplicationList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupApplicationInfo.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Get the record of the group membership application issued by yourself
|
||||
/// 获取自己发出的入群申请记录
|
||||
Future<List<GroupApplicationInfo>> getSendGroupApplicationList(
|
||||
{String? operationID}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getSendGroupApplicationList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupApplicationInfo.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Accept group application
|
||||
/// 同意进组申请
|
||||
/// 管理员或者群主同意某人进入某群
|
||||
Future<dynamic> acceptGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
required String gid,
|
||||
required String uid,
|
||||
String? handleMsg,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'acceptGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
'handleMsg': handleMsg,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Refuse group application
|
||||
/// 拒绝进组申请
|
||||
/// 管理员或者群主拒绝某人进入某群
|
||||
Future<dynamic> refuseGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
required String gid,
|
||||
required String uid,
|
||||
String? handleMsg,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'refuseGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
'handleMsg': handleMsg,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
///
|
||||
@@ -280,4 +362,8 @@ class GroupManager {
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:developer';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_openim_sdk/src/manager/im_user_manager.dart';
|
||||
|
||||
class IMManager {
|
||||
MethodChannel _channel;
|
||||
@@ -10,13 +11,13 @@ class IMManager {
|
||||
late FriendshipManager friendshipManager;
|
||||
late MessageManager messageManager;
|
||||
late GroupManager groupManager;
|
||||
late UserManager userManager;
|
||||
|
||||
// late OfflinePushManager offlinePushManager;
|
||||
// late SignalingManager signalingManager;
|
||||
late InitSDKListener _initSDKListener;
|
||||
late ConnectListener _connectListener;
|
||||
late String uid;
|
||||
late UserInfo uInfo;
|
||||
bool isInitialized = false;
|
||||
bool isLogined = false;
|
||||
|
||||
IMManager(this._channel) {
|
||||
@@ -24,6 +25,7 @@ class IMManager {
|
||||
friendshipManager = FriendshipManager(_channel);
|
||||
messageManager = MessageManager(_channel);
|
||||
groupManager = GroupManager(_channel);
|
||||
userManager = UserManager(_channel);
|
||||
// offlinePushManager = OfflinePushManager(_channel);
|
||||
// signalingManager = SignalingManager(_channel);
|
||||
_addNativeCallback(_channel);
|
||||
@@ -33,112 +35,88 @@ class IMManager {
|
||||
_channel.setMethodCallHandler((call) {
|
||||
try {
|
||||
log('Flutter : $call');
|
||||
if (call.method == ListenerType.initSDKListener) {
|
||||
if (call.method == ListenerType.connectListener) {
|
||||
String type = call.arguments['type'];
|
||||
switch (type) {
|
||||
case 'onConnectFailed':
|
||||
int? errCode = call.arguments['errCode'];
|
||||
String? errMsg = call.arguments['errMsg'];
|
||||
_connectListener.connectFailed(errCode, errMsg);
|
||||
break;
|
||||
case 'onConnecting':
|
||||
_connectListener.connecting();
|
||||
break;
|
||||
case 'onConnectSuccess':
|
||||
_connectListener.connectSuccess();
|
||||
break;
|
||||
case 'onKickedOffline':
|
||||
_connectListener.kickedOffline();
|
||||
break;
|
||||
case 'onUserSigExpired':
|
||||
_connectListener.userSigExpired();
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.userListener) {
|
||||
String type = call.arguments['type'];
|
||||
dynamic data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'onSelfInfoUpdated':
|
||||
uInfo = UserInfo.fromJson(_formatJson(data));
|
||||
_initSDKListener.selfInfoUpdated(uInfo);
|
||||
break;
|
||||
case 'onConnectFailed':
|
||||
int? errCode = call.arguments['errCode'];
|
||||
String? errMsg = call.arguments['errMsg'];
|
||||
_initSDKListener.connectFailed(errCode, errMsg);
|
||||
break;
|
||||
case 'onConnecting':
|
||||
_initSDKListener.connecting();
|
||||
break;
|
||||
case 'onConnectSuccess':
|
||||
_initSDKListener.connectSuccess();
|
||||
break;
|
||||
case 'onKickedOffline':
|
||||
_initSDKListener.kickedOffline();
|
||||
break;
|
||||
case 'onUserSigExpired':
|
||||
_initSDKListener.userSigExpired();
|
||||
userManager.userListener.selfInfoUpdated(uInfo);
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.groupListener) {
|
||||
var args = call.arguments;
|
||||
String type = args['type'];
|
||||
Map<dynamic, dynamic> map = args['data'];
|
||||
String type = call.arguments['type'];
|
||||
dynamic data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'onMemberEnter':
|
||||
groupManager.groupListener.memberEnter(
|
||||
map['groupId'],
|
||||
(_formatJson(map['memberList']) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
case 'onGroupApplicationAccepted':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupApplicationAccepted(i);
|
||||
break;
|
||||
case 'onMemberLeave':
|
||||
groupManager.groupListener.memberLeave(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['member'])),
|
||||
);
|
||||
case 'onGroupApplicationAdded':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupApplicationAdded(i);
|
||||
break;
|
||||
case 'onMemberInvited':
|
||||
groupManager.groupListener.memberInvited(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
|
||||
(_formatJson(map['memberList']) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
case 'onGroupApplicationDeleted':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupApplicationDeleted(i);
|
||||
break;
|
||||
case 'onMemberKicked':
|
||||
groupManager.groupListener.memberKicked(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
|
||||
(_formatJson(map['memberList']) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
break;
|
||||
case 'onGroupCreated':
|
||||
groupManager.groupListener.groupCreated(
|
||||
map['groupId'],
|
||||
);
|
||||
case 'onGroupApplicationRejected':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupApplicationRejected(i);
|
||||
break;
|
||||
case 'onGroupInfoChanged':
|
||||
groupManager.groupListener.groupInfoChanged(
|
||||
map['groupId'],
|
||||
GroupInfo.fromJson(_formatJson(map['groupInfo'])),
|
||||
);
|
||||
final i = GroupInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupInfoChanged(i);
|
||||
break;
|
||||
case 'onReceiveJoinApplication':
|
||||
groupManager.groupListener.receiveJoinApplication(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['member'])),
|
||||
map['opReason'],
|
||||
);
|
||||
case 'onGroupMemberAdded':
|
||||
final i = GroupMembersInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupMemberAdded(i);
|
||||
break;
|
||||
case 'onApplicationProcessed':
|
||||
groupManager.groupListener.applicationProcessed(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
|
||||
map['agreeOrReject'],
|
||||
map['opReason'],
|
||||
);
|
||||
case 'onGroupMemberDeleted':
|
||||
final i = GroupMembersInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupMemberDeleted(i);
|
||||
break;
|
||||
case 'onGroupMemberInfoChanged':
|
||||
final i = GroupMembersInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.groupMemberInfoChanged(i);
|
||||
break;
|
||||
case 'onJoinedGroupAdded':
|
||||
final i = GroupInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.joinedGroupAdded(i);
|
||||
break;
|
||||
case 'onJoinedGroupDeleted':
|
||||
final i = GroupInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.joinedGroupDeleted(i);
|
||||
break;
|
||||
case 'onReceiveJoinGroupApplicationAdded':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.receiveJoinGroupApplicationAdded(i);
|
||||
break;
|
||||
case 'onReceiveJoinGroupApplicationDeleted':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.receiveJoinGroupApplicationDeleted(i);
|
||||
break;
|
||||
// case 'onMemberInfoChanged':
|
||||
// break;
|
||||
// case 'onGroupDismissed':
|
||||
// break;
|
||||
// case 'onGroupRecycled':
|
||||
// break;
|
||||
//
|
||||
// case 'onGrantAdministrator':
|
||||
// break;
|
||||
// case 'onRevokeAdministrator':
|
||||
// break;
|
||||
// case 'onQuitFromGroup':
|
||||
// break;
|
||||
// case 'onReceiveRESTCustomData':
|
||||
// break;
|
||||
// case 'onGroupAttributeChanged':
|
||||
// break;
|
||||
}
|
||||
} else if (call.method == ListenerType.advancedMsgListener) {
|
||||
var type = call.arguments['type'];
|
||||
@@ -147,29 +125,17 @@ class IMManager {
|
||||
case 'onRecvNewMessage':
|
||||
var value = call.arguments['data']['newMessage'];
|
||||
var msg = Message.fromJson(_formatJson(value));
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.recvNewMessage(msg);
|
||||
}
|
||||
}
|
||||
messageManager.advancedMsgListener.recvNewMessage(msg);
|
||||
break;
|
||||
case 'onRecvMessageRevoked':
|
||||
var value = call.arguments['data']['revokedMessage'];
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.recvMessageRevoked(value);
|
||||
}
|
||||
}
|
||||
messageManager.advancedMsgListener.recvMessageRevoked(value);
|
||||
break;
|
||||
case 'onRecvC2CReadReceipt':
|
||||
var value = call.arguments['data']['haveReadMessage'];
|
||||
var l = _formatJson(value) as List;
|
||||
var list = l.map((e) => HaveReadInfo.fromJson(e)).toList();
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.recvC2CReadReceipt(list);
|
||||
}
|
||||
}
|
||||
messageManager.advancedMsgListener.recvC2CReadReceipt(list);
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.msgSendProgressListener) {
|
||||
@@ -226,38 +192,43 @@ class IMManager {
|
||||
} else if (call.method == ListenerType.friendListener) {
|
||||
String type = call.arguments['type'];
|
||||
dynamic data = call.arguments['data'];
|
||||
UserInfo u = UserInfo.fromJson(_formatJson(data));
|
||||
|
||||
switch (type) {
|
||||
case 'onBlackListAdd':
|
||||
friendshipManager.friendshipListener.blackListAdd(u);
|
||||
case 'onBlacklistAdded':
|
||||
final u = BlacklistInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.blacklistAdded(u);
|
||||
break;
|
||||
case 'onBlackListDeleted':
|
||||
friendshipManager.friendshipListener.blackListDeleted(u);
|
||||
case 'onBlacklistDeleted':
|
||||
final u = BlacklistInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.blacklistDeleted(u);
|
||||
break;
|
||||
case 'onFriendApplicationListAccept':
|
||||
friendshipManager.friendshipListener
|
||||
.friendApplicationListAccept(u);
|
||||
case 'onFriendApplicationAccepted':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.friendApplicationAccepted(u);
|
||||
break;
|
||||
case 'onFriendApplicationListAdded':
|
||||
friendshipManager.friendshipListener
|
||||
.friendApplicationListAdded(u);
|
||||
case 'onFriendApplicationAdded':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.friendApplicationAdded(u);
|
||||
break;
|
||||
case 'onFriendApplicationListDeleted':
|
||||
friendshipManager.friendshipListener
|
||||
.friendApplicationListDeleted(u);
|
||||
case 'onFriendApplicationDeleted':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.friendApplicationDeleted(u);
|
||||
break;
|
||||
case 'onFriendApplicationListReject':
|
||||
friendshipManager.friendshipListener
|
||||
.friendApplicationListReject(u);
|
||||
case 'onFriendApplicationListRejected':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.friendApplicationRejected(u);
|
||||
break;
|
||||
case 'onFriendInfoChanged':
|
||||
final u = FriendInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.friendInfoChanged(u);
|
||||
break;
|
||||
case 'onFriendListAdded':
|
||||
friendshipManager.friendshipListener.friendListAdded(u);
|
||||
case 'onFriendAdded':
|
||||
final u = FriendInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.friendAdded(u);
|
||||
break;
|
||||
case 'onFriendListDeleted':
|
||||
friendshipManager.friendshipListener.friendListDeleted(u);
|
||||
case 'onFriendDeleted':
|
||||
final u = FriendInfo.fromJson(_formatJson(data));
|
||||
friendshipManager.friendshipListener.friendDeleted(u);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -272,61 +243,74 @@ class IMManager {
|
||||
/// Initialize SDK
|
||||
///
|
||||
/// [platform] Refer to [IMPlatform]
|
||||
/// [ipApi] Api server ip address
|
||||
/// [ipWs] WebSocket ip address
|
||||
/// [dbPath] Data storage directory
|
||||
/// [apiAddr] Api server ip address
|
||||
/// [wsAddr] WebSocket ip address
|
||||
/// [dataDir] Data storage directory
|
||||
/// 初始化SDK
|
||||
/// [platform] 平台编号[IMPlatform]
|
||||
/// [ipApi] SDK api地址
|
||||
/// [ipWs] SDK websocket地址
|
||||
/// [dbPath] SDK数据库存储目录
|
||||
/// [apiAddr] SDK api地址
|
||||
/// [wsAddr] SDK websocket地址
|
||||
/// [dataDir] SDK数据库存储目录
|
||||
Future<dynamic> initSDK({
|
||||
required int platform,
|
||||
required String ipApi,
|
||||
required String ipWs,
|
||||
required String dbPath,
|
||||
required InitSDKListener listener,
|
||||
required String apiAddr,
|
||||
required String wsAddr,
|
||||
required String dataDir,
|
||||
required ConnectListener listener,
|
||||
int logLevel = 6,
|
||||
String? objectStorage,
|
||||
String? operationID,
|
||||
}) {
|
||||
_initSDKListener = listener;
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'initSDK',
|
||||
_buildParam(
|
||||
{
|
||||
"platform": platform,
|
||||
"ipApi": ipApi,
|
||||
"ipWs": ipWs,
|
||||
"dbDir": dbPath
|
||||
},
|
||||
))
|
||||
.then((value) => isInitialized = true);
|
||||
_connectListener = listener;
|
||||
return _channel.invokeMethod(
|
||||
'initSDK',
|
||||
_buildParam(
|
||||
{
|
||||
"platform": platform,
|
||||
"api_addr": apiAddr,
|
||||
"ws_addr": wsAddr,
|
||||
"data_dir": dataDir,
|
||||
"log_level": logLevel,
|
||||
"object_storage": objectStorage,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
@deprecated
|
||||
Future<dynamic> unInitSDK() {
|
||||
return _channel.invokeMethod('unInitSDK', _buildParam({})).then((value) {
|
||||
isInitialized = false;
|
||||
return value;
|
||||
});
|
||||
return _channel.invokeMethod('unInitSDK', _buildParam({}));
|
||||
}
|
||||
|
||||
/// Login sdk
|
||||
/// 登录
|
||||
Future<UserInfo> login({required String uid, required String token}) async {
|
||||
this.uid = uid;
|
||||
Future<UserInfo> login({
|
||||
required String uid,
|
||||
required String token,
|
||||
String? operationID,
|
||||
}) async {
|
||||
await _channel.invokeMethod(
|
||||
'login',
|
||||
_buildParam({'uid': uid, 'token': token}),
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'token': token,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
this.isLogined = true;
|
||||
this.uInfo = (await getUsersInfo([uid])).first;
|
||||
this.uid = uid;
|
||||
this.uInfo = await userManager.getSelfUserInfo();
|
||||
return uInfo;
|
||||
}
|
||||
|
||||
/// Logout sdk
|
||||
/// 登出
|
||||
Future<dynamic> logout() async {
|
||||
var value = await _channel.invokeMethod('logout', _buildParam({}));
|
||||
Future<dynamic> logout({String? operationID}) async {
|
||||
var value = await _channel.invokeMethod(
|
||||
'logout',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
this.isLogined = false;
|
||||
return value;
|
||||
}
|
||||
@@ -337,65 +321,24 @@ class IMManager {
|
||||
|
||||
/// Current user id
|
||||
/// 获取当前登录用户id
|
||||
Future<String> getLoginUid() async => uid;
|
||||
Future<String> getLoginUserID() async => uid;
|
||||
|
||||
/// Current user info
|
||||
/// 获取当前登录用户信息
|
||||
Future<UserInfo> getLoginUserInfo() async => uInfo;
|
||||
|
||||
/// Modify current user info
|
||||
/// 修改当前登录用户资料
|
||||
Future<String?> setSelfInfo(
|
||||
{String? name,
|
||||
String? icon,
|
||||
int? gender,
|
||||
String? mobile,
|
||||
String? birth,
|
||||
String? email,
|
||||
String? ex}) =>
|
||||
_channel.invokeMethod(
|
||||
'setSelfInfo',
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'name': name,
|
||||
'icon': icon,
|
||||
'gender': gender,
|
||||
'mobile': mobile,
|
||||
'birth': birth,
|
||||
'email': email,
|
||||
'ex': ex,
|
||||
}));
|
||||
|
||||
/// Query user information
|
||||
/// 查询用户信息
|
||||
Future<List<UserInfo>> getUsersInfo(List<String> uidList) => _channel
|
||||
.invokeMethod('getUsersInfo', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
///
|
||||
Future enabledSDKLog({required bool enabled}) => _channel.invokeMethod(
|
||||
'setSdkLog', _buildParam({'sdkLog': enabled ? 0 : 1}));
|
||||
|
||||
///
|
||||
Future<dynamic> forceSyncLoginUerInfo(List<String> uidList) =>
|
||||
_channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
|
||||
|
||||
///
|
||||
// Future<dynamic> forceReConn() {
|
||||
// return _channel.invokeMethod('forceReConn', _buildParam({}));
|
||||
// }
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "imManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static List<UserInfo> _toList(String value) =>
|
||||
(_formatJson(value) as List).map((e) => UserInfo.fromJson(e)).toList();
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,28 +5,20 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
class MessageManager {
|
||||
MethodChannel _channel;
|
||||
List<AdvancedMsgListener> advancedMsgListeners = List.empty(growable: true);
|
||||
|
||||
// List<AdvancedMsgListener> advancedMsgListeners = List.empty(growable: true);
|
||||
MsgSendProgressListener? msgSendProgressListener;
|
||||
late AdvancedMsgListener advancedMsgListener;
|
||||
|
||||
MessageManager(this._channel);
|
||||
|
||||
/// Add a message listener
|
||||
/// Set a message listener
|
||||
/// 消息监听
|
||||
Future addAdvancedMsgListener(AdvancedMsgListener listener) {
|
||||
advancedMsgListeners.add(listener);
|
||||
Future setAdvancedMsgListener(AdvancedMsgListener listener) {
|
||||
this.advancedMsgListener = listener;
|
||||
// advancedMsgListeners.add(listener);
|
||||
return _channel.invokeMethod(
|
||||
'addAdvancedMsgListener',
|
||||
_buildParam({
|
||||
'id': listener.id,
|
||||
}));
|
||||
}
|
||||
|
||||
/// Remove a message listener
|
||||
@deprecated
|
||||
Future removeAdvancedMsgListener(AdvancedMsgListener listener) {
|
||||
advancedMsgListeners.remove(listener);
|
||||
return _channel.invokeMethod(
|
||||
'removeAdvancedMsgListener',
|
||||
'setAdvancedMsgListener',
|
||||
_buildParam({
|
||||
'id': listener.id,
|
||||
}));
|
||||
@@ -47,7 +39,8 @@ class MessageManager {
|
||||
required Message message,
|
||||
String? userID,
|
||||
String? groupID,
|
||||
bool onlineUserOnly = false,
|
||||
OfflinePushInfo? offlinePushInfo,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'sendMessage',
|
||||
@@ -55,7 +48,8 @@ class MessageManager {
|
||||
'message': message.toJson(),
|
||||
'userID': userID ?? '',
|
||||
'groupID': groupID ?? '',
|
||||
'onlineUserOnly': onlineUserOnly,
|
||||
'offlinePushInfo': offlinePushInfo?.toJson(),
|
||||
'operationID': _checkOperationID(operationID),
|
||||
})) /*.then((value) => _toObj(value))*/;
|
||||
|
||||
/// Find all history message
|
||||
@@ -67,40 +61,57 @@ class MessageManager {
|
||||
String? groupID,
|
||||
Message? startMsg,
|
||||
int? count,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getHistoryMessageList',
|
||||
_buildParam({
|
||||
'userID': userID ?? '',
|
||||
'startMsg': startMsg?.toJson() /*?? {}*/,
|
||||
'groupID': groupID ?? '',
|
||||
'startClientMsgID': startMsg?.clientMsgID ?? '',
|
||||
'count': count ?? 10,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Revoke the sent information
|
||||
/// 撤回消息
|
||||
Future revokeMessage({required Message message}) =>
|
||||
_channel.invokeMethod('revokeMessage', _buildParam(message.toJson()));
|
||||
Future revokeMessage({
|
||||
required Message message,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'revokeMessage',
|
||||
_buildParam(message.toJson()
|
||||
..addAll({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
})));
|
||||
|
||||
/// Delete message
|
||||
/// 删除消息
|
||||
Future deleteMessageFromLocalStorage({required Message message}) =>
|
||||
Future deleteMessageFromLocalStorage({
|
||||
required Message message,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'deleteMessageFromLocalStorage', _buildParam(message.toJson()));
|
||||
'deleteMessageFromLocalStorage',
|
||||
_buildParam(message.toJson()
|
||||
..addAll({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
})));
|
||||
|
||||
///
|
||||
@deprecated
|
||||
Future deleteMessages({required List<Message> msgList}) =>
|
||||
_channel.invokeMethod('deleteMessages',
|
||||
_buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
|
||||
// Future deleteMessages({required List<Message> msgList}) =>
|
||||
// _channel.invokeMethod('deleteMessages',
|
||||
// _buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
|
||||
|
||||
///
|
||||
Future insertSingleMessageToLocalStorage({
|
||||
String? receiverID,
|
||||
String? senderID,
|
||||
Message? message,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'insertSingleMessageToLocalStorage',
|
||||
@@ -108,53 +119,68 @@ class MessageManager {
|
||||
"message": message?.toJson(),
|
||||
"receiverID": receiverID,
|
||||
"senderID": senderID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Query the message according to the message id
|
||||
Future findMessages({required List<String> messageIDList}) =>
|
||||
_channel.invokeMethod(
|
||||
'findMessages',
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
}));
|
||||
// Future findMessages({required List<String> messageIDList}) =>
|
||||
// _channel.invokeMethod(
|
||||
// 'findMessages',
|
||||
// _buildParam({
|
||||
// "messageIDList": messageIDList,
|
||||
// }));
|
||||
|
||||
/// Mark c2c message as read
|
||||
/// 标记c2c消息已读
|
||||
Future markC2CMessageAsRead({
|
||||
required String userID,
|
||||
required List<String> messageIDList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'markC2CMessageAsRead',
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
"userID": userID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Typing
|
||||
/// 正在输入提示
|
||||
Future typingStatusUpdate({
|
||||
required String userID,
|
||||
bool typing = false,
|
||||
String? msgTip,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'typingStatusUpdate',
|
||||
_buildParam({
|
||||
"typing": typing ? 'yes' : 'no',
|
||||
"msgTip": msgTip,
|
||||
"userID": userID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Create text message
|
||||
/// 创建文本消息
|
||||
Future<Message> createTextMessage({required String text}) => _channel
|
||||
.invokeMethod('createTextMessage', _buildParam({'text': text}))
|
||||
.then((value) => _toObj(value));
|
||||
Future<Message> createTextMessage({
|
||||
required String text,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createTextMessage',
|
||||
_buildParam({
|
||||
'text': text,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create @ message
|
||||
/// 创建@消息
|
||||
Future<Message> createTextAtMessage({
|
||||
required String text,
|
||||
required List<String> atUidList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -162,26 +188,40 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'text': text,
|
||||
'atUserList': atUidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create picture message
|
||||
/// 创建图片消息
|
||||
Future<Message> createImageMessage({required String imagePath}) => _channel
|
||||
.invokeMethod(
|
||||
'createImageMessage',
|
||||
_buildParam({'imagePath': imagePath}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
Future<Message> createImageMessage({
|
||||
required String imagePath,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createImageMessage',
|
||||
_buildParam({
|
||||
'imagePath': imagePath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create picture message
|
||||
/// 创建图片消息
|
||||
Future<Message> createImageMessageFromFullPath({required String imagePath}) =>
|
||||
Future<Message> createImageMessageFromFullPath({
|
||||
required String imagePath,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createImageMessageFromFullPath',
|
||||
_buildParam({'imagePath': imagePath}),
|
||||
_buildParam({
|
||||
'imagePath': imagePath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -190,11 +230,16 @@ class MessageManager {
|
||||
Future<Message> createSoundMessage({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createSoundMessage',
|
||||
_buildParam({'soundPath': soundPath, "duration": duration}),
|
||||
_buildParam({
|
||||
'soundPath': soundPath,
|
||||
"duration": duration,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -203,11 +248,16 @@ class MessageManager {
|
||||
Future<Message> createSoundMessageFromFullPath({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createSoundMessageFromFullPath',
|
||||
_buildParam({'soundPath': soundPath, "duration": duration}),
|
||||
_buildParam({
|
||||
'soundPath': soundPath,
|
||||
"duration": duration,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -218,6 +268,7 @@ class MessageManager {
|
||||
required String videoType,
|
||||
required int duration,
|
||||
required String snapshotPath,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -227,6 +278,7 @@ class MessageManager {
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -237,6 +289,7 @@ class MessageManager {
|
||||
required String videoType,
|
||||
required int duration,
|
||||
required String snapshotPath,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -246,6 +299,7 @@ class MessageManager {
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -254,6 +308,7 @@ class MessageManager {
|
||||
Future<Message> createFileMessage({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
String? operationID,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
@@ -261,6 +316,7 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'filePath': filePath,
|
||||
'fileName': fileName,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
@@ -270,6 +326,7 @@ class MessageManager {
|
||||
Future<Message> createFileMessageFromFullPath({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -277,6 +334,7 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'filePath': filePath,
|
||||
'fileName': fileName,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -286,6 +344,7 @@ class MessageManager {
|
||||
required List<Message> messageList,
|
||||
required String title,
|
||||
required List<String> summaryList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -294,17 +353,22 @@ class MessageManager {
|
||||
'messageList': messageList.map((e) => e.toJson()).toList(),
|
||||
'title': title,
|
||||
'summaryList': summaryList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create forward message
|
||||
/// 创建转发消息
|
||||
Future<Message> createForwardMessage({required Message message}) {
|
||||
Future<Message> createForwardMessage({
|
||||
required Message message,
|
||||
String? operationID,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createForwardMessage',
|
||||
_buildParam({
|
||||
'message': message.toJson(),
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
@@ -315,6 +379,7 @@ class MessageManager {
|
||||
required double latitude,
|
||||
required double longitude,
|
||||
required String description,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -323,6 +388,7 @@ class MessageManager {
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'description': description,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -332,6 +398,7 @@ class MessageManager {
|
||||
required String data,
|
||||
required String extension,
|
||||
required String description,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -340,6 +407,7 @@ class MessageManager {
|
||||
'data': data,
|
||||
'extension': extension,
|
||||
'description': description,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -348,6 +416,7 @@ class MessageManager {
|
||||
Future<Message> createQuoteMessage({
|
||||
required String text,
|
||||
required Message quoteMsg,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
@@ -355,6 +424,7 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'quoteText': text,
|
||||
'quoteMessage': quoteMsg.toJson(),
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
@@ -362,24 +432,42 @@ class MessageManager {
|
||||
/// 创建卡片消息
|
||||
Future<Message> createCardMessage({
|
||||
required Map<String, dynamic> data,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createCardMessage',
|
||||
_buildParam({
|
||||
'cardMessage': data,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Clear all c2c history message
|
||||
/// 清空单聊消息记录
|
||||
Future<dynamic> clearC2CHistoryMessage({required String uid}) => _channel
|
||||
.invokeMethod('clearC2CHistoryMessage', _buildParam({"userID": uid}));
|
||||
Future<dynamic> clearC2CHistoryMessage({
|
||||
required String uid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'clearC2CHistoryMessage',
|
||||
_buildParam({
|
||||
"userID": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Clear all group history
|
||||
/// 清空组消息记录
|
||||
Future<dynamic> clearGroupHistoryMessage({required String gid}) => _channel
|
||||
.invokeMethod('clearGroupHistoryMessage', _buildParam({"groupID": gid}));
|
||||
Future<dynamic> clearGroupHistoryMessage({
|
||||
required String gid,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'clearGroupHistoryMessage',
|
||||
_buildParam({
|
||||
"groupID": gid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
///
|
||||
// void forceSyncMsg() {
|
||||
@@ -401,4 +489,8 @@ class MessageManager {
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
95
lib/src/manager/im_user_manager.dart
Normal file
95
lib/src/manager/im_user_manager.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
class UserManager {
|
||||
MethodChannel _channel;
|
||||
late UserListener userListener;
|
||||
|
||||
UserManager(this._channel);
|
||||
|
||||
/// Observe user info changes
|
||||
/// 用户资料改变监听
|
||||
Future setUserListener(UserListener listener) {
|
||||
this.userListener = listener;
|
||||
return _channel.invokeMethod('setUserListener', _buildParam({}));
|
||||
}
|
||||
|
||||
/// Query user information
|
||||
/// 获取用户资料
|
||||
Future<List<UserInfo>> getUsersInfo({
|
||||
required List<String> uidList,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getUsersInfo',
|
||||
_buildParam({
|
||||
'uidList': uidList,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
|
||||
/// Get the information of the currently logged in user
|
||||
/// 获取当前登录用户的信息
|
||||
Future<UserInfo> getSelfUserInfo({
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getSelfUserInfo',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => UserInfo.fromJson(_formatJson(value)));
|
||||
|
||||
/// Modify current user info
|
||||
/// 修改当前登录用户资料
|
||||
Future<String?> setSelfInfo({
|
||||
String? nickname,
|
||||
String? faceURL,
|
||||
int? gender,
|
||||
int? appMangerLevel,
|
||||
String? phoneNumber,
|
||||
String? birth,
|
||||
String? email,
|
||||
String? ex,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setSelfInfo',
|
||||
_buildParam({
|
||||
// 'userID': userID,
|
||||
'nickname': nickname,
|
||||
'faceURL': faceURL,
|
||||
'gender': gender,
|
||||
'appMangerLevel': appMangerLevel,
|
||||
'phoneNumber': phoneNumber,
|
||||
'birth': birth,
|
||||
'email': email,
|
||||
'ex': ex,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "userManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static List<T> _toList<T>(String? value, T f(Map map)) {
|
||||
var list = _formatJson(value);
|
||||
if (null == list) return <T>[];
|
||||
return (list as List).map((e) => f(e)).toList();
|
||||
}
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,16 @@ class ConversationInfo {
|
||||
String? userID;
|
||||
String? groupID;
|
||||
String? showName;
|
||||
String? faceUrl;
|
||||
String? faceURL;
|
||||
int? recvMsgOpt;
|
||||
int? unreadCount;
|
||||
int? groupAtType;
|
||||
Message? latestMsg;
|
||||
int? latestMsgSendTime;
|
||||
String? draftText;
|
||||
int? draftTimestamp;
|
||||
|
||||
/// pinned value is 1
|
||||
dynamic isPinned;
|
||||
int? draftTextTime;
|
||||
bool? isPinned;
|
||||
String? ext;
|
||||
|
||||
ConversationInfo(
|
||||
{required this.conversationID,
|
||||
@@ -27,13 +27,13 @@ class ConversationInfo {
|
||||
this.userID,
|
||||
this.groupID,
|
||||
this.showName,
|
||||
this.faceUrl,
|
||||
this.faceURL,
|
||||
this.recvMsgOpt,
|
||||
this.unreadCount,
|
||||
this.latestMsg,
|
||||
this.latestMsgSendTime,
|
||||
this.draftText,
|
||||
this.draftTimestamp,
|
||||
this.draftTextTime,
|
||||
this.isPinned});
|
||||
|
||||
ConversationInfo.fromJson(Map<String, dynamic> json)
|
||||
@@ -43,7 +43,7 @@ class ConversationInfo {
|
||||
userID = json['userID'];
|
||||
groupID = json['groupID'];
|
||||
showName = json['showName'];
|
||||
faceUrl = json['faceUrl'];
|
||||
faceURL = json['faceURL'];
|
||||
recvMsgOpt = json['recvMsgOpt'];
|
||||
unreadCount = json['unreadCount'];
|
||||
// latestMsg = json['latestMsg'];
|
||||
@@ -60,7 +60,7 @@ class ConversationInfo {
|
||||
|
||||
latestMsgSendTime = json['latestMsgSendTime'];
|
||||
draftText = json['draftText'];
|
||||
draftTimestamp = json['draftTimestamp'];
|
||||
draftTextTime = json['draftTextTime'];
|
||||
isPinned = json['isPinned'];
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ class ConversationInfo {
|
||||
data['userID'] = this.userID;
|
||||
data['groupID'] = this.groupID;
|
||||
data['showName'] = this.showName;
|
||||
data['faceUrl'] = this.faceUrl;
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['recvMsgOpt'] = this.recvMsgOpt;
|
||||
data['unreadCount'] = this.unreadCount;
|
||||
data['latestMsg'] = this.latestMsg?.toJson();
|
||||
data['latestMsgSendTime'] = this.latestMsgSendTime;
|
||||
data['draftText'] = this.draftText;
|
||||
data['draftTimestamp'] = this.draftTimestamp;
|
||||
data['draftTextTime'] = this.draftTextTime;
|
||||
data['isPinned'] = this.isPinned;
|
||||
return data;
|
||||
}
|
||||
@@ -86,7 +86,6 @@ class ConversationInfo {
|
||||
|
||||
bool get isGroupChat => conversationType == ConversationType.group_chat;
|
||||
|
||||
bool get isTop => isPinned == 1;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
|
||||
@@ -3,30 +3,43 @@ class GroupInfo {
|
||||
String? groupName;
|
||||
String? notification;
|
||||
String? introduction;
|
||||
String? faceUrl;
|
||||
String? ownerId;
|
||||
String? faceURL;
|
||||
String? ownerUserID;
|
||||
int? createTime;
|
||||
int? memberCount;
|
||||
int? status;
|
||||
String? creatorUserID;
|
||||
int? groupType;
|
||||
String? ex;
|
||||
|
||||
GroupInfo(
|
||||
{required this.groupID,
|
||||
this.groupName,
|
||||
this.notification,
|
||||
this.introduction,
|
||||
this.faceUrl,
|
||||
this.ownerId,
|
||||
this.createTime,
|
||||
this.memberCount});
|
||||
GroupInfo({
|
||||
required this.groupID,
|
||||
this.groupName,
|
||||
this.notification,
|
||||
this.introduction,
|
||||
this.faceURL,
|
||||
this.ownerUserID,
|
||||
this.createTime,
|
||||
this.memberCount,
|
||||
this.status,
|
||||
this.creatorUserID,
|
||||
this.groupType,
|
||||
this.ex,
|
||||
});
|
||||
|
||||
GroupInfo.fromJson(Map<String, dynamic> json) : groupID = json['groupID'] {
|
||||
/*groupID = json['groupID'];*/
|
||||
groupName = json['groupName'];
|
||||
notification = json['notification'];
|
||||
introduction = json['introduction'];
|
||||
faceUrl = json['faceUrl'];
|
||||
ownerId = json['ownerId'];
|
||||
faceURL = json['faceURL'];
|
||||
ownerUserID = json['ownerUserID'];
|
||||
createTime = json['createTime'];
|
||||
memberCount = json['memberCount'];
|
||||
status = json['status'];
|
||||
creatorUserID = json['creatorUserID'];
|
||||
groupType = json['groupType'];
|
||||
ex = json['ex'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -35,217 +48,257 @@ class GroupInfo {
|
||||
data['groupName'] = this.groupName;
|
||||
data['notification'] = this.notification;
|
||||
data['introduction'] = this.introduction;
|
||||
data['faceUrl'] = this.faceUrl;
|
||||
data['ownerId'] = this.ownerId;
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['ownerUserID'] = this.ownerUserID;
|
||||
data['createTime'] = this.createTime;
|
||||
data['memberCount'] = this.memberCount;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMembersList {
|
||||
int? nextSeq;
|
||||
List<GroupMembersInfo>? data;
|
||||
|
||||
GroupMembersList({this.nextSeq, this.data});
|
||||
|
||||
GroupMembersList.fromJson(Map<String, dynamic> json) {
|
||||
nextSeq = json['nextSeq'];
|
||||
if (json['data'] is List) {
|
||||
data = (json['data'] as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['nextSeq'] = this.nextSeq;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['status'] = this.status;
|
||||
data['creatorUserID'] = this.creatorUserID;
|
||||
data['groupType'] = this.groupType;
|
||||
data['ex'] = this.ex;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMembersInfo {
|
||||
String? groupID;
|
||||
String? userId;
|
||||
int? role;
|
||||
String? userID;
|
||||
String? nickname;
|
||||
String? faceURL;
|
||||
int? roleLevel;
|
||||
int? joinTime;
|
||||
String? nickName;
|
||||
String? faceUrl;
|
||||
dynamic ext;
|
||||
int? joinSource;
|
||||
String? operatorUserID;
|
||||
String? ext;
|
||||
|
||||
GroupMembersInfo({
|
||||
this.groupID,
|
||||
this.userId,
|
||||
this.role,
|
||||
this.userID,
|
||||
this.roleLevel,
|
||||
this.joinTime,
|
||||
this.nickName,
|
||||
this.faceUrl,
|
||||
this.nickname,
|
||||
this.faceURL,
|
||||
this.ext,
|
||||
this.joinSource,
|
||||
this.operatorUserID,
|
||||
});
|
||||
|
||||
GroupMembersInfo.fromJson(Map<String, dynamic> json) {
|
||||
groupID = json['groupID'];
|
||||
userId = json['userId'];
|
||||
role = json['role'];
|
||||
userID = json['userID'];
|
||||
roleLevel = json['roleLevel'];
|
||||
joinTime = json['joinTime'];
|
||||
nickName = json['nickName'];
|
||||
faceUrl = json['faceUrl'];
|
||||
nickname = json['nickname'];
|
||||
faceURL = json['faceURL'];
|
||||
ext = json['ext'];
|
||||
joinSource = json['joinSource'];
|
||||
operatorUserID = json['operatorUserID'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['groupID'] = this.groupID;
|
||||
data['userId'] = this.userId;
|
||||
data['role'] = this.role;
|
||||
data['userID'] = this.userID;
|
||||
data['roleLevel'] = this.roleLevel;
|
||||
data['joinTime'] = this.joinTime;
|
||||
data['nickName'] = this.nickName;
|
||||
data['faceUrl'] = this.faceUrl;
|
||||
data['nickname'] = this.nickname;
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['ext'] = this.ext;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupInviteResult {
|
||||
String? uid;
|
||||
int? result;
|
||||
|
||||
GroupInviteResult({this.uid, this.result});
|
||||
|
||||
GroupInviteResult.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
result = json['result'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['uid'] = this.uid;
|
||||
data['result'] = this.result;
|
||||
data['joinSource'] = this.joinSource;
|
||||
data['operatorUserID'] = this.operatorUserID;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupMemberRole {
|
||||
String? uid;
|
||||
int? setRole;
|
||||
String? userID;
|
||||
|
||||
GroupMemberRole({this.uid, this.setRole});
|
||||
/// 1 ordinary member, 2 group owners, 3 administrators
|
||||
/// 1普通成员, 2群主,3管理员
|
||||
int? roleLevel;
|
||||
|
||||
GroupMemberRole({this.userID, this.roleLevel = 1});
|
||||
|
||||
GroupMemberRole.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
setRole = json['setRole'];
|
||||
userID = json['userID'];
|
||||
roleLevel = json['roleLevel'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['uid'] = this.uid;
|
||||
data['setRole'] = this.setRole;
|
||||
data['userID'] = this.userID;
|
||||
data['roleLevel'] = this.roleLevel;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupApplicationInfo {
|
||||
String? id;
|
||||
String? groupID;
|
||||
String? fromUserID;
|
||||
String? toUserID;
|
||||
int? flag; //INIT = 0, REFUSE = -1, AGREE = 1
|
||||
String? groupName;
|
||||
String? notification;
|
||||
String? introduction;
|
||||
String? groupFaceURL;
|
||||
int? createTime;
|
||||
int? status;
|
||||
String? creatorUserID;
|
||||
int? groupType;
|
||||
String? ownerUserID;
|
||||
int? memberCount;
|
||||
String? userID;
|
||||
String? nickname;
|
||||
String? userFaceURL;
|
||||
int? gender;
|
||||
int? handleResult; //REFUSE = -1, AGREE = 1
|
||||
String? reqMsg;
|
||||
String? handledMsg;
|
||||
int? createTime;
|
||||
String? fromUserNickName;
|
||||
String? toUserNickName;
|
||||
String? fromUserFaceURL;
|
||||
String? toUserFaceURL;
|
||||
String? handledUser;
|
||||
int? type; //APPLICATION = 0, INVITE = 1
|
||||
int? handleStatus; //UNHANDLED = 0, BY_OTHER = 1, BY_SELF = 2
|
||||
int? handleResult; //REFUSE = 0, AGREE = 1
|
||||
int? reqTime;
|
||||
String? handleUserID;
|
||||
int? handledTime;
|
||||
String? ex;
|
||||
|
||||
GroupApplicationInfo(
|
||||
{this.id,
|
||||
this.groupID,
|
||||
this.fromUserID,
|
||||
this.toUserID,
|
||||
this.flag,
|
||||
this.reqMsg,
|
||||
this.handledMsg,
|
||||
this.createTime,
|
||||
this.fromUserNickName,
|
||||
this.toUserNickName,
|
||||
this.fromUserFaceURL,
|
||||
this.toUserFaceURL,
|
||||
this.handledUser,
|
||||
this.type,
|
||||
this.handleStatus,
|
||||
this.handleResult});
|
||||
GroupApplicationInfo({
|
||||
this.groupID,
|
||||
this.groupName,
|
||||
this.notification,
|
||||
this.introduction,
|
||||
this.groupFaceURL,
|
||||
this.createTime,
|
||||
this.status,
|
||||
this.creatorUserID,
|
||||
this.groupType,
|
||||
this.ownerUserID,
|
||||
this.memberCount,
|
||||
this.userID,
|
||||
this.nickname,
|
||||
this.userFaceURL,
|
||||
this.gender,
|
||||
this.handleResult,
|
||||
this.reqMsg,
|
||||
this.handledMsg,
|
||||
this.reqTime,
|
||||
this.handleUserID,
|
||||
this.handledTime,
|
||||
this.ex,
|
||||
});
|
||||
|
||||
GroupApplicationInfo.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
groupID = json['groupID'];
|
||||
fromUserID = json['fromUserID'];
|
||||
toUserID = json['toUserID'];
|
||||
flag = json['flag'];
|
||||
groupName = json['groupName'];
|
||||
notification = json['notification'];
|
||||
introduction = json['introduction'];
|
||||
groupFaceURL = json['groupFaceURL'];
|
||||
createTime = json['createTime'];
|
||||
status = json['status'];
|
||||
creatorUserID = json['creatorUserID'];
|
||||
groupType = json['groupType'];
|
||||
ownerUserID = json['ownerUserID'];
|
||||
memberCount = json['memberCount'];
|
||||
userID = json['userID'];
|
||||
nickname = json['nickname'];
|
||||
userFaceURL = json['userFaceURL'];
|
||||
gender = json['gender'];
|
||||
handleResult = json['handleResult'];
|
||||
reqMsg = json['reqMsg'];
|
||||
handledMsg = json['handledMsg'];
|
||||
createTime = json['createTime'];
|
||||
fromUserNickName = json['fromUserNickName'];
|
||||
toUserNickName = json['toUserNickName'];
|
||||
fromUserFaceURL = json['fromUserFaceURL'];
|
||||
toUserFaceURL = json['toUserFaceURL'];
|
||||
handledUser = json['handledUser'];
|
||||
type = json['type'];
|
||||
handleStatus = json['handleStatus'];
|
||||
handleResult = json['handleResult'];
|
||||
reqTime = json['reqTime'];
|
||||
handleUserID = json['handleUserID'];
|
||||
handledTime = json['handledTime'];
|
||||
ex = json['ex'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
final data = Map<String, dynamic>();
|
||||
data['groupID'] = this.groupID;
|
||||
data['fromUserID'] = this.fromUserID;
|
||||
data['toUserID'] = this.toUserID;
|
||||
data['flag'] = this.flag;
|
||||
data['groupName'] = this.groupName;
|
||||
data['notification'] = this.notification;
|
||||
data['introduction'] = this.introduction;
|
||||
data['groupFaceURL'] = this.groupFaceURL;
|
||||
data['createTime'] = this.createTime;
|
||||
data['status'] = this.status;
|
||||
data['creatorUserID'] = this.creatorUserID;
|
||||
data['groupType'] = this.groupType;
|
||||
data['ownerUserID'] = this.ownerUserID;
|
||||
data['memberCount'] = this.memberCount;
|
||||
data['userID'] = this.userID;
|
||||
data['nickname'] = this.nickname;
|
||||
data['userFaceURL'] = this.userFaceURL;
|
||||
data['gender'] = this.gender;
|
||||
data['handleResult'] = this.handleResult;
|
||||
data['reqMsg'] = this.reqMsg;
|
||||
data['handledMsg'] = this.handledMsg;
|
||||
data['createTime'] = this.createTime;
|
||||
data['fromUserNickName'] = this.fromUserNickName;
|
||||
data['toUserNickName'] = this.toUserNickName;
|
||||
data['fromUserFaceURL'] = this.fromUserFaceURL;
|
||||
data['toUserFaceURL'] = this.toUserFaceURL;
|
||||
data['handledUser'] = this.handledUser;
|
||||
data['type'] = this.type;
|
||||
data['handleStatus'] = this.handleStatus;
|
||||
data['handleResult'] = this.handleResult;
|
||||
data['reqTime'] = this.reqTime;
|
||||
data['handleUserID'] = this.handleUserID;
|
||||
data['handledTime'] = this.handledTime;
|
||||
data['ex'] = this.ex;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class GroupApplicationList {
|
||||
int? count;
|
||||
List<GroupApplicationInfo>? user;
|
||||
class GroupInviteResult {
|
||||
String? userID;
|
||||
int? result;
|
||||
|
||||
GroupApplicationList({this.count, this.user});
|
||||
GroupInviteResult({this.userID, this.result});
|
||||
|
||||
GroupApplicationList.fromJson(Map<String, dynamic> json) {
|
||||
count = json['count'];
|
||||
if (json['user'] is List) {
|
||||
user = (json['user'] as List)
|
||||
.map((e) => GroupApplicationInfo.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
GroupInviteResult.fromJson(Map<String, dynamic> json) {
|
||||
userID = json['userID'];
|
||||
result = json['result'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['count'] = this.count;
|
||||
if (this.user != null) {
|
||||
data['user'] = this.user!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['userID'] = this.userID;
|
||||
data['result'] = this.result;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// class GroupMembersList {
|
||||
// int? nextSeq;
|
||||
// List<GroupMembersInfo>? data;
|
||||
//
|
||||
// GroupMembersList({this.nextSeq, this.data});
|
||||
//
|
||||
// GroupMembersList.fromJson(Map<String, dynamic> json) {
|
||||
// nextSeq = json['nextSeq'];
|
||||
// if (json['data'] is List) {
|
||||
// data = (json['data'] as List)
|
||||
// .map((e) => GroupMembersInfo.fromJson(e))
|
||||
// .toList();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['nextSeq'] = this.nextSeq;
|
||||
// if (this.data != null) {
|
||||
// data['data'] = this.data!.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class GroupApplicationList {
|
||||
// int? count;
|
||||
// List<GroupApplicationInfo>? user;
|
||||
//
|
||||
// GroupApplicationList({this.count, this.user});
|
||||
//
|
||||
// GroupApplicationList.fromJson(Map<String, dynamic> json) {
|
||||
// count = json['count'];
|
||||
// if (json['user'] is List) {
|
||||
// user = (json['user'] as List)
|
||||
// .map((e) => GroupApplicationInfo.fromJson(e))
|
||||
// .toList();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['count'] = this.count;
|
||||
// if (this.user != null) {
|
||||
// data['user'] = this.user!.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -3,6 +3,9 @@ class Message {
|
||||
String? serverMsgID;
|
||||
int? createTime;
|
||||
int? sendTime;
|
||||
|
||||
/// [ConversationType]
|
||||
int? sessionType;
|
||||
String? sendID;
|
||||
String? recvID;
|
||||
int? msgFrom;
|
||||
@@ -10,8 +13,7 @@ class Message {
|
||||
/// [MessageType]
|
||||
int? contentType;
|
||||
int? platformID;
|
||||
List<String>? forceList;
|
||||
String? senderNickName;
|
||||
String? senderNickname;
|
||||
String? senderFaceUrl;
|
||||
String? groupID;
|
||||
String? content;
|
||||
@@ -20,11 +22,10 @@ class Message {
|
||||
|
||||
/// [MessageStatus]
|
||||
int? status;
|
||||
String? remark;
|
||||
OfflinePushInfo? offlinePush;
|
||||
String? attachedInfo;
|
||||
String? ex;
|
||||
dynamic ext;
|
||||
|
||||
/// [ConversationType]
|
||||
int? sessionType;
|
||||
PictureElem? pictureElem;
|
||||
SoundElem? soundElem;
|
||||
VideoElem? videoElem;
|
||||
@@ -34,28 +35,30 @@ class Message {
|
||||
CustomElem? customElem;
|
||||
QuoteElem? quoteElem;
|
||||
MergeElem? mergeElem;
|
||||
NotificationElem? notificationElem;
|
||||
|
||||
Message({
|
||||
this.clientMsgID,
|
||||
this.serverMsgID,
|
||||
this.createTime,
|
||||
this.sendTime,
|
||||
this.sessionType,
|
||||
this.sendID,
|
||||
this.recvID,
|
||||
this.msgFrom,
|
||||
this.contentType,
|
||||
this.platformID,
|
||||
this.forceList,
|
||||
this.senderNickName,
|
||||
this.senderNickname,
|
||||
this.senderFaceUrl,
|
||||
this.groupID,
|
||||
this.content,
|
||||
this.seq,
|
||||
this.isRead,
|
||||
this.status,
|
||||
this.remark,
|
||||
this.offlinePush,
|
||||
this.attachedInfo,
|
||||
this.ex,
|
||||
this.ext,
|
||||
this.sessionType,
|
||||
this.pictureElem,
|
||||
this.soundElem,
|
||||
this.videoElem,
|
||||
@@ -65,6 +68,7 @@ class Message {
|
||||
this.customElem,
|
||||
this.quoteElem,
|
||||
this.mergeElem,
|
||||
this.notificationElem,
|
||||
});
|
||||
|
||||
Message.fromJson(
|
||||
@@ -78,17 +82,18 @@ class Message {
|
||||
msgFrom = json['msgFrom'];
|
||||
contentType = json['contentType'];
|
||||
platformID = json['platformID'];
|
||||
if (json['forceList'] is List) {
|
||||
forceList = (json['forceList'] as List).map((e) => '$e').toList();
|
||||
}
|
||||
senderNickName = json['senderNickName'];
|
||||
senderNickname = json['senderNickname'];
|
||||
senderFaceUrl = json['senderFaceUrl'];
|
||||
groupID = json['groupID'];
|
||||
content = json['content'];
|
||||
seq = json['seq'];
|
||||
isRead = json['isRead'];
|
||||
status = json['status'];
|
||||
remark = json['remark'];
|
||||
offlinePush = json['offlinePush'] != null
|
||||
? OfflinePushInfo.fromJson(json['offlinePush'])
|
||||
: null;
|
||||
attachedInfo = json['attachedInfo'];
|
||||
ex = json['ex'];
|
||||
ext = json['ext'];
|
||||
sessionType = json['sessionType'];
|
||||
pictureElem = json['pictureElem'] != null
|
||||
@@ -116,6 +121,9 @@ class Message {
|
||||
mergeElem = json['mergeElem'] != null
|
||||
? MergeElem.fromJson(json['mergeElem'])
|
||||
: null;
|
||||
notificationElem = json['notificationElem'] != null
|
||||
? NotificationElem.fromJson(json['notificationElem'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -129,15 +137,16 @@ class Message {
|
||||
data['msgFrom'] = this.msgFrom;
|
||||
data['contentType'] = this.contentType;
|
||||
data['platformID'] = this.platformID;
|
||||
data['forceList'] = this.forceList;
|
||||
data['senderNickName'] = this.senderNickName;
|
||||
data['senderNickname'] = this.senderNickname;
|
||||
data['senderFaceUrl'] = this.senderFaceUrl;
|
||||
data['groupID'] = this.groupID;
|
||||
data['content'] = this.content;
|
||||
data['seq'] = this.seq;
|
||||
data['isRead'] = this.isRead;
|
||||
data['status'] = this.status;
|
||||
data['remark'] = this.remark;
|
||||
data['offlinePush'] = this.offlinePush?.toJson();
|
||||
data['attachedInfo'] = this.attachedInfo;
|
||||
data['ex'] = this.ex;
|
||||
data['ext'] = this.ext;
|
||||
data['sessionType'] = this.sessionType;
|
||||
data['pictureElem'] = this.pictureElem?.toJson();
|
||||
@@ -149,6 +158,7 @@ class Message {
|
||||
data['customElem'] = this.customElem?.toJson();
|
||||
data['quoteElem'] = this.quoteElem?.toJson();
|
||||
data['mergeElem'] = this.mergeElem?.toJson();
|
||||
data['notificationElem'] = this.notificationElem?.toJson();
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -205,7 +215,7 @@ class PictureElem {
|
||||
}
|
||||
|
||||
class PictureInfo {
|
||||
String? uuID;
|
||||
String? uuid;
|
||||
String? type;
|
||||
int? size;
|
||||
int? width;
|
||||
@@ -213,10 +223,10 @@ class PictureInfo {
|
||||
String? url;
|
||||
|
||||
PictureInfo(
|
||||
{this.uuID, this.type, this.size, this.width, this.height, this.url});
|
||||
{this.uuid, this.type, this.size, this.width, this.height, this.url});
|
||||
|
||||
PictureInfo.fromJson(Map<String, dynamic> json) {
|
||||
uuID = json['uuID'];
|
||||
uuid = json['uuid'];
|
||||
type = json['type'];
|
||||
size = json['size'];
|
||||
width = json['width'];
|
||||
@@ -226,7 +236,7 @@ class PictureInfo {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['uuID'] = this.uuID;
|
||||
data['uuid'] = this.uuid;
|
||||
data['type'] = this.type;
|
||||
data['size'] = this.size;
|
||||
data['width'] = this.width;
|
||||
@@ -237,21 +247,21 @@ class PictureInfo {
|
||||
}
|
||||
|
||||
class SoundElem {
|
||||
String? uuID;
|
||||
String? uuid;
|
||||
String? soundPath;
|
||||
String? sourceUrl;
|
||||
int? dataSize;
|
||||
int? duration;
|
||||
|
||||
SoundElem(
|
||||
{this.uuID,
|
||||
{this.uuid,
|
||||
this.soundPath,
|
||||
this.sourceUrl,
|
||||
this.dataSize,
|
||||
this.duration});
|
||||
|
||||
SoundElem.fromJson(Map<String, dynamic> json) {
|
||||
uuID = json['uuID'];
|
||||
uuid = json['uuid'];
|
||||
soundPath = json['soundPath'];
|
||||
sourceUrl = json['sourceUrl'];
|
||||
dataSize = json['dataSize'];
|
||||
@@ -260,7 +270,7 @@ class SoundElem {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['uuID'] = this.uuID;
|
||||
data['uuid'] = this.uuid;
|
||||
data['soundPath'] = this.soundPath;
|
||||
data['sourceUrl'] = this.sourceUrl;
|
||||
data['dataSize'] = this.dataSize;
|
||||
@@ -332,17 +342,17 @@ class VideoElem {
|
||||
|
||||
class FileElem {
|
||||
String? filePath;
|
||||
String? uuID;
|
||||
String? uuid;
|
||||
String? sourceUrl;
|
||||
String? fileName;
|
||||
int? fileSize;
|
||||
|
||||
FileElem(
|
||||
{this.filePath, this.uuID, this.sourceUrl, this.fileName, this.fileSize});
|
||||
{this.filePath, this.uuid, this.sourceUrl, this.fileName, this.fileSize});
|
||||
|
||||
FileElem.fromJson(Map<String, dynamic> json) {
|
||||
filePath = json['filePath'];
|
||||
uuID = json['uuID'];
|
||||
uuid = json['uuid'];
|
||||
sourceUrl = json['sourceUrl'];
|
||||
fileName = json['fileName'];
|
||||
fileSize = json['fileSize'];
|
||||
@@ -351,7 +361,7 @@ class FileElem {
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['filePath'] = this.filePath;
|
||||
data['uuID'] = this.uuID;
|
||||
data['uuid'] = this.uuid;
|
||||
data['sourceUrl'] = this.sourceUrl;
|
||||
data['fileName'] = this.fileName;
|
||||
data['fileSize'] = this.fileSize;
|
||||
@@ -485,6 +495,25 @@ class MergeElem {
|
||||
}
|
||||
}
|
||||
|
||||
class NotificationElem {
|
||||
String? detail;
|
||||
String? defaultTips;
|
||||
|
||||
NotificationElem({this.detail, this.defaultTips});
|
||||
|
||||
NotificationElem.fromJson(Map<String, dynamic> json) {
|
||||
detail = json['detail'];
|
||||
defaultTips = json['defaultTips'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['detail'] = this.detail;
|
||||
data['defaultTips'] = this.defaultTips;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class HaveReadInfo {
|
||||
String? uid;
|
||||
List<String>? msgIDList;
|
||||
@@ -523,3 +552,32 @@ class HaveReadInfo {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class OfflinePushInfo {
|
||||
String? title;
|
||||
String? desc;
|
||||
String? ex;
|
||||
String? iOSPushSound;
|
||||
bool? iOSBadgeCount;
|
||||
|
||||
OfflinePushInfo(
|
||||
{this.title, this.desc, this.ex, this.iOSPushSound, this.iOSBadgeCount});
|
||||
|
||||
OfflinePushInfo.fromJson(Map<String, dynamic> json) {
|
||||
title = json['title'];
|
||||
desc = json['desc'];
|
||||
ex = json['ex'];
|
||||
iOSPushSound = json['iOSPushSound'];
|
||||
iOSBadgeCount = json['iOSBadgeCount'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['title'] = this.title;
|
||||
data['desc'] = this.desc;
|
||||
data['ex'] = this.ex;
|
||||
data['iOSPushSound'] = this.iOSPushSound;
|
||||
data['iOSBadgeCount'] = this.iOSBadgeCount;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +1,388 @@
|
||||
/// Is a friend not in the blacklist
|
||||
/// 是好友不在黑名单
|
||||
/// Not a friend on the blacklist
|
||||
/// 不是好友在黑名单
|
||||
/// Not a friend is not on the blacklist
|
||||
/// 不是好友不在黑名单
|
||||
class UserInfo {
|
||||
String uid;
|
||||
String? name;
|
||||
String? icon;
|
||||
String? userID;
|
||||
String? nickname;
|
||||
String? faceURL;
|
||||
int? gender;
|
||||
String? mobile;
|
||||
String? birth;
|
||||
String? phoneNumber;
|
||||
int? birth;
|
||||
String? email;
|
||||
String? ex;
|
||||
String? comment;
|
||||
int? isInBlackList;
|
||||
String? reqMessage;
|
||||
String? applyTime;
|
||||
int? flag;
|
||||
int? createTime;
|
||||
String? remark;
|
||||
|
||||
UserInfo(
|
||||
{required this.uid,
|
||||
this.name,
|
||||
this.icon,
|
||||
this.gender,
|
||||
this.mobile,
|
||||
this.birth,
|
||||
this.email,
|
||||
this.ex,
|
||||
this.comment,
|
||||
this.isInBlackList,
|
||||
this.reqMessage,
|
||||
this.applyTime,
|
||||
this.flag});
|
||||
PublicUserInfo? publicInfo;
|
||||
FriendInfo? friendInfo;
|
||||
BlacklistInfo? blackInfo;
|
||||
|
||||
UserInfo.fromJson(Map<String, dynamic> json) : uid = json['uid'] {
|
||||
name = json['name'];
|
||||
icon = json['icon'];
|
||||
bool? isFriendship;
|
||||
bool? isBlacklist;
|
||||
|
||||
UserInfo({
|
||||
this.publicInfo,
|
||||
this.friendInfo,
|
||||
this.blackInfo,
|
||||
this.isFriendship,
|
||||
this.isBlacklist,
|
||||
//
|
||||
this.userID,
|
||||
this.nickname,
|
||||
this.faceURL,
|
||||
this.phoneNumber,
|
||||
this.birth,
|
||||
this.gender,
|
||||
this.email,
|
||||
this.ex,
|
||||
this.createTime,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
// UserInfo.self(Map<String, dynamic> 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<String, dynamic> 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;
|
||||
//
|
||||
isFriendship = friendInfo != null;
|
||||
isBlacklist = blackInfo != null;
|
||||
|
||||
userID = json['userID'] ?? _userID;
|
||||
nickname = json['nickname'] ?? _nickname;
|
||||
faceURL = json['faceURL'] ?? _faceUrl;
|
||||
gender = json['gender'] ?? _gender;
|
||||
phoneNumber = json['phoneNumber'] ?? _phoneNumber;
|
||||
birth = json['birth'] ?? _birth;
|
||||
email = json['email'] ?? _email;
|
||||
remark = json['remark'] ?? _remark;
|
||||
ex = json['ex'];
|
||||
createTime = json['createTime'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = Map<String, dynamic>();
|
||||
data['publicInfo'] = this.publicInfo?.toJson();
|
||||
data['friendInfo'] = this.friendInfo?.toJson();
|
||||
data['blackInfo'] = this.blackInfo?.toJson();
|
||||
//
|
||||
data['isFriendship'] = this.isFriendship;
|
||||
data['isBlacklist'] = this.isBlacklist;
|
||||
data['userID'] = this.userID;
|
||||
data['nickname'] = this.nickname;
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['gender'] = this.gender;
|
||||
data['phoneNumber'] = this.phoneNumber;
|
||||
data['birth'] = this.birth;
|
||||
data['email'] = this.email;
|
||||
data['ex'] = this.ex;
|
||||
data['createTime'] = this.createTime;
|
||||
data['remark'] = this.remark;
|
||||
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 _nickname => isFriendship!
|
||||
? friendInfo?.nickname
|
||||
: (isBlacklist! ? blackInfo?.nickname : publicInfo?.nickname);
|
||||
|
||||
String? get _faceUrl => isFriendship!
|
||||
? friendInfo?.faceURL
|
||||
: (isBlacklist! ? blackInfo?.faceURL : publicInfo?.faceURL);
|
||||
|
||||
int? get _gender => isFriendship!
|
||||
? friendInfo?.gender
|
||||
: (isBlacklist! ? blackInfo?.gender : publicInfo?.gender);
|
||||
|
||||
String? get _phoneNumber => friendInfo?.phoneNumber;
|
||||
|
||||
int? get _birth => friendInfo?.birth;
|
||||
|
||||
String? get _email => friendInfo?.email;
|
||||
|
||||
String? get _remark => friendInfo?.remark;
|
||||
|
||||
String getShowName() => _trimBlank(remark) ?? _trimBlank(nickname) ?? userID!;
|
||||
|
||||
static String? _trimBlank(String? value) {
|
||||
if (value == null || value.trim().isEmpty) return null;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
class PublicUserInfo {
|
||||
String? userID;
|
||||
String? nickname;
|
||||
String? faceURL;
|
||||
int? gender;
|
||||
int? appMangerLevel;
|
||||
|
||||
PublicUserInfo({
|
||||
this.userID,
|
||||
this.nickname,
|
||||
this.faceURL,
|
||||
this.gender,
|
||||
this.appMangerLevel,
|
||||
});
|
||||
|
||||
PublicUserInfo.fromJson(Map<String, dynamic> json) {
|
||||
userID = json['userID'];
|
||||
nickname = json['nickname'];
|
||||
faceURL = json['faceURL'];
|
||||
gender = json['gender'];
|
||||
mobile = json['mobile'];
|
||||
appMangerLevel = json['appMangerLevel'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = Map<String, dynamic>();
|
||||
data['userID'] = this.userID;
|
||||
data['nickname'] = this.nickname;
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['gender'] = this.gender;
|
||||
data['appMangerLevel'] = this.appMangerLevel;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class FriendInfo {
|
||||
String? userID;
|
||||
String? nickname;
|
||||
String? faceURL;
|
||||
int? gender;
|
||||
String? phoneNumber;
|
||||
int? birth;
|
||||
String? email;
|
||||
String? remark;
|
||||
String? ex;
|
||||
int? createTime;
|
||||
int? addSource;
|
||||
String? operatorUserID;
|
||||
|
||||
FriendInfo({
|
||||
this.userID,
|
||||
this.nickname,
|
||||
this.faceURL,
|
||||
this.gender,
|
||||
this.phoneNumber,
|
||||
this.birth,
|
||||
this.email,
|
||||
this.remark,
|
||||
this.ex,
|
||||
this.createTime,
|
||||
this.addSource,
|
||||
this.operatorUserID,
|
||||
});
|
||||
|
||||
FriendInfo.fromJson(Map<String, dynamic> json) {
|
||||
// ownerUserID = json['ownerUserID'];
|
||||
userID = json['userID'];
|
||||
remark = json['remark'];
|
||||
createTime = json['createTime'];
|
||||
addSource = json['addSource'];
|
||||
operatorUserID = json['operatorUserID'];
|
||||
nickname = json['nickname'];
|
||||
faceURL = json['faceURL'];
|
||||
gender = json['gender'];
|
||||
phoneNumber = json['phoneNumber'];
|
||||
birth = json['birth'];
|
||||
email = json['email'];
|
||||
ex = json['ex'];
|
||||
comment = json['comment'];
|
||||
isInBlackList = json['isInBlackList'];
|
||||
reqMessage = json['reqMessage'];
|
||||
applyTime = json['applyTime'];
|
||||
flag = json['flag'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = Map<String, dynamic>();
|
||||
// data['ownerUserID'] = this.ownerUserID;
|
||||
data['userID'] = this.userID;
|
||||
data['remark'] = this.remark;
|
||||
data['createTime'] = this.createTime;
|
||||
data['addSource'] = this.addSource;
|
||||
data['operatorUserID'] = this.operatorUserID;
|
||||
data['nickname'] = this.nickname;
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['gender'] = this.gender;
|
||||
data['phoneNumber'] = this.phoneNumber;
|
||||
data['birth'] = this.birth;
|
||||
data['email'] = this.email;
|
||||
data['ex'] = this.ex;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class BlacklistInfo {
|
||||
String? userID;
|
||||
String? nickname;
|
||||
String? faceURL;
|
||||
int? gender;
|
||||
int? createTime;
|
||||
int? addSource;
|
||||
String? operatorUserID;
|
||||
String? ex;
|
||||
|
||||
BlacklistInfo({
|
||||
this.userID,
|
||||
this.nickname,
|
||||
this.faceURL,
|
||||
this.gender,
|
||||
this.createTime,
|
||||
this.addSource,
|
||||
this.operatorUserID,
|
||||
this.ex,
|
||||
});
|
||||
|
||||
BlacklistInfo.fromJson(Map<String, dynamic> json) {
|
||||
userID = json['userID'];
|
||||
nickname = json['nickname'];
|
||||
faceURL = json['faceURL'];
|
||||
gender = json['gender'];
|
||||
createTime = json['createTime'];
|
||||
addSource = json['addSource'];
|
||||
operatorUserID = json['operatorUserID'];
|
||||
ex = json['ex'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = Map<String, dynamic>();
|
||||
data['userID'] = this.userID;
|
||||
data['nickname'] = this.nickname;
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['gender'] = this.gender;
|
||||
data['createTime'] = this.createTime;
|
||||
data['addSource'] = this.addSource;
|
||||
data['operatorUserID'] = this.operatorUserID;
|
||||
data['ex'] = this.ex;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class FriendshipInfo {
|
||||
String? userID;
|
||||
|
||||
/// 1 means friend (and not blacklist)
|
||||
/// 1表示好友(并且不是黑名单)
|
||||
int? result;
|
||||
|
||||
FriendshipInfo({this.userID, this.result});
|
||||
|
||||
FriendshipInfo.fromJson(Map<String, dynamic> json) {
|
||||
userID = json['userID'];
|
||||
result = json['result'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['uid'] = this.uid;
|
||||
data['name'] = this.name;
|
||||
data['icon'] = this.icon;
|
||||
data['gender'] = this.gender;
|
||||
data['mobile'] = this.mobile;
|
||||
data['birth'] = this.birth;
|
||||
data['email'] = this.email;
|
||||
data['userID'] = this.userID;
|
||||
data['result'] = this.result;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class FriendApplicationInfo {
|
||||
String? fromUserID;
|
||||
String? fromNickname;
|
||||
String? fromFaceURL;
|
||||
int? fromGender;
|
||||
String? toUserID;
|
||||
String? toNickname;
|
||||
String? toFaceURL;
|
||||
int? toGender;
|
||||
int? handleResult;
|
||||
String? reqMsg;
|
||||
int? createTime;
|
||||
String? handlerUserID;
|
||||
String? handleMsg;
|
||||
int? handleTime;
|
||||
String? ex;
|
||||
|
||||
FriendApplicationInfo(
|
||||
{this.fromUserID,
|
||||
this.fromNickname,
|
||||
this.fromFaceURL,
|
||||
this.fromGender,
|
||||
this.toUserID,
|
||||
this.toNickname,
|
||||
this.toFaceURL,
|
||||
this.toGender,
|
||||
this.handleResult,
|
||||
this.reqMsg,
|
||||
this.createTime,
|
||||
this.handlerUserID,
|
||||
this.handleMsg,
|
||||
this.handleTime,
|
||||
this.ex});
|
||||
|
||||
FriendApplicationInfo.fromJson(Map<String, dynamic> json) {
|
||||
fromUserID = json['fromUserID'];
|
||||
fromNickname = json['fromNickname'];
|
||||
fromFaceURL = json['fromFaceURL'];
|
||||
fromGender = json['fromGender'];
|
||||
toUserID = json['toUserID'];
|
||||
toNickname = json['toNickname'];
|
||||
toFaceURL = json['toFaceURL'];
|
||||
toGender = json['toGender'];
|
||||
handleResult = json['handleResult'];
|
||||
reqMsg = json['reqMsg'];
|
||||
createTime = json['createTime'];
|
||||
handlerUserID = json['handlerUserID'];
|
||||
handleMsg = json['handleMsg'];
|
||||
handleTime = json['handleTime'];
|
||||
ex = json['ex'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = Map<String, dynamic>();
|
||||
data['fromUserID'] = this.fromUserID;
|
||||
data['fromNickname'] = this.fromNickname;
|
||||
data['fromFaceURL'] = this.fromFaceURL;
|
||||
data['fromGender'] = this.fromGender;
|
||||
data['toUserID'] = this.toUserID;
|
||||
data['toNickname'] = this.toNickname;
|
||||
data['toFaceURL'] = this.toFaceURL;
|
||||
data['toGender'] = this.toGender;
|
||||
data['handleResult'] = this.handleResult;
|
||||
data['reqMsg'] = this.reqMsg;
|
||||
data['createTime'] = this.createTime;
|
||||
data['handlerUserID'] = this.handlerUserID;
|
||||
data['handleMsg'] = this.handleMsg;
|
||||
data['handleTime'] = this.handleTime;
|
||||
data['ex'] = this.ex;
|
||||
data['comment'] = this.comment;
|
||||
data['isInBlackList'] = this.isInBlackList;
|
||||
data['reqMessage'] = this.reqMessage;
|
||||
data['applyTime'] = this.applyTime;
|
||||
data['flag'] = this.flag;
|
||||
return data;
|
||||
}
|
||||
|
||||
String getShowName() {
|
||||
if (null != comment && comment!.trim().isNotEmpty) {
|
||||
return comment!;
|
||||
} else if (null != name && name!.trim().isNotEmpty) {
|
||||
return name!;
|
||||
}
|
||||
return uid;
|
||||
}
|
||||
|
||||
bool get isMan => gender == 1;
|
||||
|
||||
bool get isWoman => gender == 2;
|
||||
|
||||
/// blacklist
|
||||
bool get isBlocked => isInBlackList == 1;
|
||||
|
||||
/// friend application waiting handle
|
||||
bool get isWaitingHandle => flag == 0;
|
||||
bool get isWaitingHandle => handleResult == 0;
|
||||
|
||||
/// friend application agreed
|
||||
bool get isAgreed => flag == 1;
|
||||
bool get isAgreed => handleResult == 1;
|
||||
|
||||
/// friend application rejected
|
||||
bool get isRejected => flag == -1;
|
||||
|
||||
/// exist friendship
|
||||
bool get isFriendship => isAgreed;
|
||||
bool get isRejected => handleResult == -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user