fix: Fixed some issues.

main
Brett 2 years ago
parent d07495fff6
commit 67251ae7ea
  1. 1
      lib/flutter_openim_sdk.dart
  2. 3
      lib/src/enum/message_type.dart
  3. 4
      lib/src/manager/im_friendship_manager.dart
  4. 64
      lib/src/manager/im_group_manager.dart
  5. 20
      lib/src/manager/im_manager.dart
  6. 8
      lib/src/manager/im_user_manager.dart
  7. 47
      lib/src/models/init_config.dart
  8. 15
      lib/src/models/search_info.dart
  9. 64
      lib/src/models/user_info.dart

@ -29,6 +29,7 @@ export 'src/manager/im_message_manager.dart';
export 'src/manager/im_user_manager.dart'; export 'src/manager/im_user_manager.dart';
export 'src/models/conversation_info.dart'; export 'src/models/conversation_info.dart';
export 'src/models/group_info.dart'; export 'src/models/group_info.dart';
export 'src/models/init_config.dart';
export 'src/models/message.dart'; export 'src/models/message.dart';
export 'src/models/notification_info.dart'; export 'src/models/notification_info.dart';
export 'src/models/search_info.dart'; export 'src/models/search_info.dart';

@ -30,9 +30,6 @@ class MessageType {
/// Custom /// Custom
static const custom = 110; static const custom = 110;
/// Has Read Receipt
static const hasReadReceipt = 112;
/// Typing /// Typing
static const typing = 113; static const typing = 113;

@ -203,7 +203,7 @@ class FriendshipManager {
/// [isSearchUserID] Whether to search for friend IDs with keywords (note: cannot be false at the same time), defaults to false if empty /// [isSearchUserID] Whether to search for friend IDs with keywords (note: cannot be false at the same time), defaults to false if empty
/// [isSearchNickname] Whether to search by nickname with keywords, defaults to false if empty /// [isSearchNickname] Whether to search by nickname with keywords, defaults to false if empty
/// [isSearchRemark] Whether to search by remark name with keywords, defaults to false if empty /// [isSearchRemark] Whether to search by remark name with keywords, defaults to false if empty
Future<List<FriendInfo>> searchFriends({ Future<List<SearchFriendInfo>> searchFriends({
List<String> keywordList = const [], List<String> keywordList = const [],
bool isSearchUserID = false, bool isSearchUserID = false,
bool isSearchNickname = false, bool isSearchNickname = false,
@ -223,7 +223,7 @@ class FriendshipManager {
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => .then((value) =>
Utils.toList(value, (map) => FriendInfo.fromJson(map))); Utils.toList(value, (map) => SearchFriendInfo.fromJson(map)));
static Map _buildParam(Map param) { static Map _buildParam(Map param) {
param["ManagerName"] = "friendshipManager"; param["ManagerName"] = "friendshipManager";

@ -33,7 +33,8 @@ class GroupManager {
'reason': reason, 'reason': reason,
"operationID": Utils.checkOperationID(operationID), "operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupInviteResult.fromJson(map))); .then((value) =>
Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
/// Remove group members /// Remove group members
/// [groupID] Group ID /// [groupID] Group ID
@ -54,7 +55,8 @@ class GroupManager {
'reason': reason, 'reason': reason,
"operationID": Utils.checkOperationID(operationID), "operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupInviteResult.fromJson(map))); .then((value) =>
Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
/// Query group member information /// Query group member information
/// [groupID] Group ID /// [groupID] Group ID
@ -72,7 +74,8 @@ class GroupManager {
'userIDList': userIDList, 'userIDList': userIDList,
"operationID": Utils.checkOperationID(operationID), "operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); .then((value) =>
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
/// Paginate and retrieve the group member list /// Paginate and retrieve the group member list
/// [groupID] Group ID /// [groupID] Group ID
@ -96,7 +99,8 @@ class GroupManager {
'count': count, 'count': count,
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); .then((value) =>
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
/// Paginate and retrieve the group member list as a map /// Paginate and retrieve the group member list as a map
/// [groupID] Group ID /// [groupID] Group ID
@ -177,7 +181,8 @@ class GroupManager {
'ownerUserID': ownerUserID, 'ownerUserID': ownerUserID,
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toObj(value, (map) => GroupInfo.fromJson(map))); .then(
(value) => Utils.toObj(value, (map) => GroupInfo.fromJson(map)));
/// Edit group information /// Edit group information
Future<dynamic> setGroupInfo({ Future<dynamic> setGroupInfo({
@ -221,7 +226,8 @@ class GroupManager {
'groupIDList': groupIDList, 'groupIDList': groupIDList,
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map))); .then(
(value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
/// Apply to join a group, requiring approval from an administrator or the group. /// Apply to join a group, requiring approval from an administrator or the group.
/// [joinSource] 2: Invited, 3: Searched, 4: Using a QR code /// [joinSource] 2: Invited, 3: Searched, 4: Using a QR code
@ -269,22 +275,28 @@ class GroupManager {
})); }));
/// Handle group membership applications received as a group owner or administrator /// Handle group membership applications received as a group owner or administrator
Future<List<GroupApplicationInfo>> getGroupApplicationListAsRecipient({String? operationID}) => _channel Future<List<GroupApplicationInfo>> getGroupApplicationListAsRecipient(
.invokeMethod( {String? operationID}) =>
'getGroupApplicationListAsRecipient', _channel
_buildParam({ .invokeMethod(
'operationID': Utils.checkOperationID(operationID), 'getGroupApplicationListAsRecipient',
})) _buildParam({
.then((value) => Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map))); 'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
/// Get the list of group membership applications sent by the user /// Get the list of group membership applications sent by the user
Future<List<GroupApplicationInfo>> getGroupApplicationListAsApplicant({String? operationID}) => _channel Future<List<GroupApplicationInfo>> getGroupApplicationListAsApplicant(
.invokeMethod( {String? operationID}) =>
'getGroupApplicationListAsApplicant', _channel
_buildParam({ .invokeMethod(
'operationID': Utils.checkOperationID(operationID), 'getGroupApplicationListAsApplicant',
})) _buildParam({
.then((value) => Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map))); 'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
/// Accept a group membership application as an administrator or group owner /// Accept a group membership application as an administrator or group owner
/// Note: Membership applications require approval from administrators or the group. /// Note: Membership applications require approval from administrators or the group.
@ -410,7 +422,8 @@ class GroupManager {
}, },
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map))); .then(
(value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
/// Set group member role /// Set group member role
/// [groupID] Group ID /// [groupID] Group ID
@ -453,7 +466,8 @@ class GroupManager {
'excludeUserIDList': excludeUserIDList, 'excludeUserIDList': excludeUserIDList,
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); .then((value) =>
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
/// Set group verification for joining /// Set group verification for joining
/// [groupID] Group ID /// [groupID] Group ID
@ -516,7 +530,8 @@ class GroupManager {
'groupID': groupID, 'groupID': groupID,
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); .then((value) =>
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
/// Search for group members /// Search for group members
/// [groupID] Group ID /// [groupID] Group ID
@ -548,7 +563,8 @@ class GroupManager {
}, },
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map))); .then((value) =>
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
/// Query a group /// Query a group
/// [groupID] Group ID /// [groupID] Group ID

@ -362,6 +362,26 @@ class IMManager {
}); });
} }
Future<bool?> init(
InitConfig config,
OnConnectListener listener, {
String? operationID,
}) {
this._connectListener = listener;
if (config.logFilePath == null) {
config.logFilePath = config.dataDir;
}
return _channel.invokeMethod(
'initSDK',
_buildParam(
{
...config.toMap(),
"operationID": Utils.checkOperationID(operationID),
},
),
);
}
/// Initialize the SDK /// Initialize the SDK
/// [platform] Platform ID [IMPlatform] /// [platform] Platform ID [IMPlatform]
/// [apiAddr] SDK API address /// [apiAddr] SDK API address

@ -52,11 +52,7 @@ class UserManager {
Future<String?> setSelfInfo({ Future<String?> setSelfInfo({
String? nickname, String? nickname,
String? faceURL, String? faceURL,
int? gender,
int? appManagerLevel, int? appManagerLevel,
String? phoneNumber,
int? birth,
String? email,
String? ex, String? ex,
String? operationID, String? operationID,
}) => }) =>
@ -66,11 +62,7 @@ class UserManager {
// 'userID': userID, // 'userID': userID,
'nickname': nickname, 'nickname': nickname,
'faceURL': faceURL, 'faceURL': faceURL,
'gender': gender,
'appManagerLevel': appManagerLevel, 'appManagerLevel': appManagerLevel,
'phoneNumber': phoneNumber,
'birth': birth,
'email': email,
'ex': ex, 'ex': ex,
'operationID': Utils.checkOperationID(operationID), 'operationID': Utils.checkOperationID(operationID),
})); }));

@ -0,0 +1,47 @@
class InitConfig {
int platformID;
String apiAddr;
String wsAddr;
String dataDir;
String objectStorage;
int logLevel;
bool isLogStandardOutput;
String? logFilePath;
InitConfig({
required this.platformID,
required this.apiAddr,
required this.wsAddr,
required this.dataDir,
required this.objectStorage,
this.logLevel = 6,
this.isLogStandardOutput = true,
this.logFilePath,
});
factory InitConfig.fromJson(Map<String, dynamic> json) {
return InitConfig(
platformID: json['platformID'],
apiAddr: json['apiAddr'],
wsAddr: json['wsAddr'],
dataDir: json['dataDir'],
objectStorage: json['objectStorage'],
logLevel: json['logLevel'],
isLogStandardOutput: json['isLogStandardOutput'],
logFilePath: json['logFilePath'],
);
}
Map<String, dynamic> toMap() {
return {
'platformID': platformID,
'apiAddr': apiAddr,
'wsAddr': wsAddr,
'dataDir': dataDir,
'objectStorage': objectStorage,
'logLevel': logLevel,
'isLogStandardOutput': isLogStandardOutput,
'logFilePath': logFilePath,
};
}
}

@ -114,3 +114,18 @@ class SearchParams {
return data; return data;
} }
} }
class SearchFriendInfo extends FriendInfo {
late int relationship;
SearchFriendInfo({required this.relationship}) : super();
SearchFriendInfo.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
relationship = json['relationship'];
}
Map<String, dynamic> toJson() {
final data = super.toJson();
data['relationship'] = this.relationship;
return data ?? {};
}
}

@ -197,6 +197,38 @@ class UserInfo {
int get hashCode => userID.hashCode; int get hashCode => userID.hashCode;
} }
class FullUserInfo {
/// User's public information
PublicUserInfo? publicInfo;
/// Information visible only to friends
FriendInfo? friendInfo;
/// Blacklist information
BlacklistInfo? blackInfo;
FullUserInfo.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;
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['publicInfo'] = this.publicInfo?.toJson();
data['friendInfo'] = this.friendInfo?.toJson();
data['blackInfo'] = this.blackInfo?.toJson();
return data;
}
}
class PublicUserInfo { class PublicUserInfo {
/// User ID /// User ID
String? userID; String? userID;
@ -249,6 +281,9 @@ class PublicUserInfo {
} }
class FriendInfo { class FriendInfo {
/// owner User ID
String? ownerUserID;
/// User ID /// User ID
String? userID; String? userID;
@ -286,6 +321,7 @@ class FriendInfo {
String? operatorUserID; String? operatorUserID;
FriendInfo({ FriendInfo({
this.ownerUserID,
this.userID, this.userID,
this.nickname, this.nickname,
this.faceURL, this.faceURL,
@ -301,7 +337,7 @@ class FriendInfo {
}); });
FriendInfo.fromJson(Map<String, dynamic> json) { FriendInfo.fromJson(Map<String, dynamic> json) {
// ownerUserID = json['ownerUserID']; ownerUserID = json['ownerUserID'];
userID = json['userID']; userID = json['userID'];
remark = json['remark']; remark = json['remark'];
createTime = json['createTime']; createTime = json['createTime'];
@ -318,7 +354,7 @@ class FriendInfo {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final data = Map<String, dynamic>(); final data = Map<String, dynamic>();
// data['ownerUserID'] = this.ownerUserID; data['ownerUserID'] = this.ownerUserID;
data['userID'] = this.userID; data['userID'] = this.userID;
data['remark'] = this.remark; data['remark'] = this.remark;
data['createTime'] = this.createTime; data['createTime'] = this.createTime;
@ -349,6 +385,12 @@ class BlacklistInfo {
/// Nickname /// Nickname
String? nickname; String? nickname;
/// owner User ID
String? ownerUserID;
/// block User ID
String? blockUserID;
/// Profile picture /// Profile picture
String? faceURL; String? faceURL;
@ -368,6 +410,8 @@ class BlacklistInfo {
String? ex; String? ex;
BlacklistInfo({ BlacklistInfo({
this.ownerUserID,
this.blockUserID,
this.userID, this.userID,
this.nickname, this.nickname,
this.faceURL, this.faceURL,
@ -379,6 +423,8 @@ class BlacklistInfo {
}); });
BlacklistInfo.fromJson(Map<String, dynamic> json) { BlacklistInfo.fromJson(Map<String, dynamic> json) {
ownerUserID = json['ownerUserID'];
blockUserID = json['blockUserID'];
userID = json['userID']; userID = json['userID'];
nickname = json['nickname']; nickname = json['nickname'];
faceURL = json['faceURL']; faceURL = json['faceURL'];
@ -391,6 +437,8 @@ class BlacklistInfo {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final data = Map<String, dynamic>(); final data = Map<String, dynamic>();
data['ownerUserID'] = this.ownerUserID;
data['blockUserID'] = this.blockUserID;
data['userID'] = this.userID; data['userID'] = this.userID;
data['nickname'] = this.nickname; data['nickname'] = this.nickname;
data['faceURL'] = this.faceURL; data['faceURL'] = this.faceURL;
@ -435,9 +483,6 @@ class FriendApplicationInfo {
/// Initiator user profile picture /// Initiator user profile picture
String? fromFaceURL; String? fromFaceURL;
/// Initiator user gender
int? fromGender;
/// Recipient user ID /// Recipient user ID
String? toUserID; String? toUserID;
@ -447,9 +492,6 @@ class FriendApplicationInfo {
/// Recipient user profile picture /// Recipient user profile picture
String? toFaceURL; String? toFaceURL;
/// Recipient user gender
int? toGender;
/// Handling result /// Handling result
int? handleResult; int? handleResult;
@ -475,11 +517,9 @@ class FriendApplicationInfo {
{this.fromUserID, {this.fromUserID,
this.fromNickname, this.fromNickname,
this.fromFaceURL, this.fromFaceURL,
this.fromGender,
this.toUserID, this.toUserID,
this.toNickname, this.toNickname,
this.toFaceURL, this.toFaceURL,
this.toGender,
this.handleResult, this.handleResult,
this.reqMsg, this.reqMsg,
this.createTime, this.createTime,
@ -492,11 +532,9 @@ class FriendApplicationInfo {
fromUserID = json['fromUserID']; fromUserID = json['fromUserID'];
fromNickname = json['fromNickname']; fromNickname = json['fromNickname'];
fromFaceURL = json['fromFaceURL']; fromFaceURL = json['fromFaceURL'];
fromGender = json['fromGender'];
toUserID = json['toUserID']; toUserID = json['toUserID'];
toNickname = json['toNickname']; toNickname = json['toNickname'];
toFaceURL = json['toFaceURL']; toFaceURL = json['toFaceURL'];
toGender = json['toGender'];
handleResult = json['handleResult']; handleResult = json['handleResult'];
reqMsg = json['reqMsg']; reqMsg = json['reqMsg'];
createTime = json['createTime']; createTime = json['createTime'];
@ -511,11 +549,9 @@ class FriendApplicationInfo {
data['fromUserID'] = this.fromUserID; data['fromUserID'] = this.fromUserID;
data['fromNickname'] = this.fromNickname; data['fromNickname'] = this.fromNickname;
data['fromFaceURL'] = this.fromFaceURL; data['fromFaceURL'] = this.fromFaceURL;
data['fromGender'] = this.fromGender;
data['toUserID'] = this.toUserID; data['toUserID'] = this.toUserID;
data['toNickname'] = this.toNickname; data['toNickname'] = this.toNickname;
data['toFaceURL'] = this.toFaceURL; data['toFaceURL'] = this.toFaceURL;
data['toGender'] = this.toGender;
data['handleResult'] = this.handleResult; data['handleResult'] = this.handleResult;
data['reqMsg'] = this.reqMsg; data['reqMsg'] = this.reqMsg;
data['createTime'] = this.createTime; data['createTime'] = this.createTime;

Loading…
Cancel
Save