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/models/conversation_info.dart';
export 'src/models/group_info.dart';
export 'src/models/init_config.dart';
export 'src/models/message.dart';
export 'src/models/notification_info.dart';
export 'src/models/search_info.dart';

@ -30,9 +30,6 @@ class MessageType {
/// Custom
static const custom = 110;
/// Has Read Receipt
static const hasReadReceipt = 112;
/// Typing
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
/// [isSearchNickname] Whether to search by nickname with keywords, defaults to false if empty
/// [isSearchRemark] Whether to search by remark name with keywords, defaults to false if empty
Future<List<FriendInfo>> searchFriends({
Future<List<SearchFriendInfo>> searchFriends({
List<String> keywordList = const [],
bool isSearchUserID = false,
bool isSearchNickname = false,
@ -223,7 +223,7 @@ class FriendshipManager {
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => FriendInfo.fromJson(map)));
Utils.toList(value, (map) => SearchFriendInfo.fromJson(map)));
static Map _buildParam(Map param) {
param["ManagerName"] = "friendshipManager";

@ -33,7 +33,8 @@ class GroupManager {
'reason': reason,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
.then((value) =>
Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
/// Remove group members
/// [groupID] Group ID
@ -54,7 +55,8 @@ class GroupManager {
'reason': reason,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
.then((value) =>
Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
/// Query group member information
/// [groupID] Group ID
@ -72,7 +74,8 @@ class GroupManager {
'userIDList': userIDList,
"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
/// [groupID] Group ID
@ -96,7 +99,8 @@ class GroupManager {
'count': count,
'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
/// [groupID] Group ID
@ -177,7 +181,8 @@ class GroupManager {
'ownerUserID': ownerUserID,
'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
Future<dynamic> setGroupInfo({
@ -221,7 +226,8 @@ class GroupManager {
'groupIDList': groupIDList,
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
.then(
(value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
/// Apply to join a group, requiring approval from an administrator or the group.
/// [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
Future<List<GroupApplicationInfo>> getGroupApplicationListAsRecipient({String? operationID}) => _channel
.invokeMethod(
'getGroupApplicationListAsRecipient',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
Future<List<GroupApplicationInfo>> getGroupApplicationListAsRecipient(
{String? operationID}) =>
_channel
.invokeMethod(
'getGroupApplicationListAsRecipient',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
/// Get the list of group membership applications sent by the user
Future<List<GroupApplicationInfo>> getGroupApplicationListAsApplicant({String? operationID}) => _channel
.invokeMethod(
'getGroupApplicationListAsApplicant',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
Future<List<GroupApplicationInfo>> getGroupApplicationListAsApplicant(
{String? operationID}) =>
_channel
.invokeMethod(
'getGroupApplicationListAsApplicant',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
/// Accept a group membership application as an administrator or group owner
/// Note: Membership applications require approval from administrators or the group.
@ -410,7 +422,8 @@ class GroupManager {
},
'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
/// [groupID] Group ID
@ -453,7 +466,8 @@ class GroupManager {
'excludeUserIDList': excludeUserIDList,
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
.then((value) =>
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
/// Set group verification for joining
/// [groupID] Group ID
@ -516,7 +530,8 @@ class GroupManager {
'groupID': groupID,
'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
/// [groupID] Group ID
@ -548,7 +563,8 @@ class GroupManager {
},
'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
/// [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
/// [platform] Platform ID [IMPlatform]
/// [apiAddr] SDK API address

@ -52,11 +52,7 @@ class UserManager {
Future<String?> setSelfInfo({
String? nickname,
String? faceURL,
int? gender,
int? appManagerLevel,
String? phoneNumber,
int? birth,
String? email,
String? ex,
String? operationID,
}) =>
@ -66,11 +62,7 @@ class UserManager {
// 'userID': userID,
'nickname': nickname,
'faceURL': faceURL,
'gender': gender,
'appManagerLevel': appManagerLevel,
'phoneNumber': phoneNumber,
'birth': birth,
'email': email,
'ex': ex,
'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;
}
}
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;
}
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 {
/// User ID
String? userID;
@ -249,6 +281,9 @@ class PublicUserInfo {
}
class FriendInfo {
/// owner User ID
String? ownerUserID;
/// User ID
String? userID;
@ -286,6 +321,7 @@ class FriendInfo {
String? operatorUserID;
FriendInfo({
this.ownerUserID,
this.userID,
this.nickname,
this.faceURL,
@ -301,7 +337,7 @@ class FriendInfo {
});
FriendInfo.fromJson(Map<String, dynamic> json) {
// ownerUserID = json['ownerUserID'];
ownerUserID = json['ownerUserID'];
userID = json['userID'];
remark = json['remark'];
createTime = json['createTime'];
@ -318,7 +354,7 @@ class FriendInfo {
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
// data['ownerUserID'] = this.ownerUserID;
data['ownerUserID'] = this.ownerUserID;
data['userID'] = this.userID;
data['remark'] = this.remark;
data['createTime'] = this.createTime;
@ -349,6 +385,12 @@ class BlacklistInfo {
/// Nickname
String? nickname;
/// owner User ID
String? ownerUserID;
/// block User ID
String? blockUserID;
/// Profile picture
String? faceURL;
@ -368,6 +410,8 @@ class BlacklistInfo {
String? ex;
BlacklistInfo({
this.ownerUserID,
this.blockUserID,
this.userID,
this.nickname,
this.faceURL,
@ -379,6 +423,8 @@ class BlacklistInfo {
});
BlacklistInfo.fromJson(Map<String, dynamic> json) {
ownerUserID = json['ownerUserID'];
blockUserID = json['blockUserID'];
userID = json['userID'];
nickname = json['nickname'];
faceURL = json['faceURL'];
@ -391,6 +437,8 @@ class BlacklistInfo {
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['ownerUserID'] = this.ownerUserID;
data['blockUserID'] = this.blockUserID;
data['userID'] = this.userID;
data['nickname'] = this.nickname;
data['faceURL'] = this.faceURL;
@ -435,9 +483,6 @@ class FriendApplicationInfo {
/// Initiator user profile picture
String? fromFaceURL;
/// Initiator user gender
int? fromGender;
/// Recipient user ID
String? toUserID;
@ -447,9 +492,6 @@ class FriendApplicationInfo {
/// Recipient user profile picture
String? toFaceURL;
/// Recipient user gender
int? toGender;
/// Handling result
int? handleResult;
@ -475,11 +517,9 @@ class FriendApplicationInfo {
{this.fromUserID,
this.fromNickname,
this.fromFaceURL,
this.fromGender,
this.toUserID,
this.toNickname,
this.toFaceURL,
this.toGender,
this.handleResult,
this.reqMsg,
this.createTime,
@ -492,11 +532,9 @@ class FriendApplicationInfo {
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'];
@ -511,11 +549,9 @@ class FriendApplicationInfo {
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;

Loading…
Cancel
Save