new_version1
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user