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