acceptGroupApplication static method
Implementation
static Future<V2TimCallback> acceptGroupApplication({
required String groupID,
String? reason,
required String fromUser,
required String toUser,
int? addTime,
int? type,
String? webMessageInstance,
int? handleStatus,
}) async {
if (addTime == null) {
return V2TimCallback.fromJson({
"code": "-3",
"desc": "add time is required",
});
}
String mapKey = "$fromUser-$toUser-$addTime";
if (!groupAuth.containsKey(mapKey)) {
return V2TimCallback.fromJson({
"code": "-3",
"desc": "this application is no need accept",
});
}
V2TimValueCallback<String> userres = await getLoginUser();
String currentLoginUser = "";
if (userres.code == 0) {
if (userres.data != null) {
if (userres.data!.isNotEmpty) {
currentLoginUser = userres.data!;
}
}
}
if (currentLoginUser.isEmpty) {
return V2TimCallback.fromJson({
"code": "-3",
"desc": "get current login user failed",
});
}
String auth = groupAuth.remove(mapKey) ?? "";
String key = groupAuthKey.remove(mapKey) ?? "";
String param = json.encode({
"group_handle_pendency_param_is_accept": true,
"group_handle_pendency_param_handle_msg": reason ?? "",
"group_handle_pendency_param_pendency": Map.from({
"group_pendency_group_id": groupID,
"group_pendency_form_identifier": fromUser,
"group_pendency_to_identifier": toUser,
"group_pendency_authentication": auth,
"group_pendency_pendency_type": type,
"group_pendency_key": key,
"group_pendency_handled": handleStatus,
"group_pendency_self_identifier": currentLoginUser,
})
});
String userData = Tools.generateUserData();
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
Pointer<Uint8> json_group_handle_pendency_param = Tools.string2PointerInt8(param);
int res = desktopSDK.D_TIMGroupHandlePendency(json_group_handle_pendency_param, user_data);
if (res != TIMResult.TIM_SUCC) {
return V2TimCallback.fromJson({
"code": res,
"desc": "",
});
} else {
Map<String, dynamic> data = await getAsyncData(apiKey: userData);
return V2TimCallback.fromJson({
"code": data["code"],
"desc": data["desc"],
});
}
}