deleteMessages static method
Future<V2TimCallback>
deleteMessages(
{ - required List<String> msgIDs,
- List? webMessageInstanceList,
})
Implementation
static Future<V2TimCallback> deleteMessages({
required List<String> msgIDs,
List<dynamic>? webMessageInstanceList,
}) async {
List<Map<String, dynamic>> messageList = List.empty(growable: true);
String userData = Tools.generateUserData();
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
String userDatafind = Tools.generateUserData(methodName: "findMessage");
Pointer<Uint8> user_data_find = Tools.string2PointerInt8(userDatafind);
Pointer<Uint8> json_message_id_array = Tools.string2PointerInt8(json.encode(msgIDs));
int res = desktopSDK.D_TIMMsgFindMessages(json_message_id_array, user_data_find);
if (res == TIMResult.TIM_SUCC) {
Map<String, dynamic> data = await getAsyncData(apiKey: userDatafind);
if (data["code"] == 0) {
messageList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
}
}
if (messageList.isNotEmpty) {
Pointer<Uint8> conv_id = Tools.string2PointerInt8(messageList.first["message_conv_id"]);
int conv_type = messageList.first["message_conv_type"];
Pointer<Uint8> json_msg_array = Tools.string2PointerInt8(json.encode(messageList));
int res1 = desktopSDK.D_TIMMsgListDelete(conv_id, conv_type, json_msg_array, user_data);
if (res1 != TIMResult.TIM_SUCC) {
return V2TimCallback.fromJson({
"code": res1,
"desc": "",
});
} else {
Map<String, dynamic> revoke = await getAsyncData(apiKey: userData);
return V2TimCallback.fromJson({
"code": revoke["code"],
"desc": revoke["desc"],
});
}
} else {
return V2TimCallback.fromJson({"code": -1, "desc": "message not found"});
}
}