setTopicInfo static method
Future<V2TimCallback>
setTopicInfo(
{ - required String groupID,
- required V2TimTopicInfo topicInfo,
})
Implementation
static Future<V2TimCallback> setTopicInfo({
required String groupID,
required V2TimTopicInfo topicInfo,
}) async {
String userData = Tools.generateUserData();
int flag = 0x00;
if (topicInfo.topicName != null) {
flag = flag | 0x01;
}
if (topicInfo.introduction != null) {
flag = flag | 0x01 << 2;
}
if (topicInfo.notification != null) {
flag = flag | 0x01 << 1;
}
if (topicInfo.topicFaceUrl != null) {
flag = flag | 0x01 << 3;
}
if (topicInfo.recvOpt != null) {
flag = flag | 0x01 << 4;
}
if (topicInfo.isAllMute != null) {
flag = flag | 0x01 << 8;
}
if (topicInfo.customString != null) {
flag = flag | 0x01 << 11;
}
Map<String, dynamic> param = Map.from({
"group_topic_info_topic_id": topicInfo.topicID,
"group_topic_info_topic_name": topicInfo.topicName,
"group_topic_info_introduction": topicInfo.introduction,
"group_topic_info_notification": topicInfo.notification,
"group_topic_info_topic_face_url": topicInfo.topicFaceUrl,
"group_topic_info_is_all_muted": topicInfo.isAllMute,
"group_topic_info_self_mute_time": topicInfo.selfMuteTime,
"group_topic_info_custom_string": topicInfo.customString,
"group_topic_info_recv_opt": topicInfo.recvOpt,
"group_topic_info_draft_text": topicInfo.draftText,
"group_modify_info_param_modify_flag": flag,
});
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
Pointer<Uint8> json_topic_info = Tools.string2PointerInt8(json.encode(param));
int res = desktopSDK.D_TIMGroupSetTopicInfo(json_topic_info, user_data);
if (res != TIMResult.TIM_SUCC) {
return V2TimCallback.fromJson({
"code": res,
"desc": "",
});
} else {
Map<String, dynamic> data = await getAsyncData(apiKey: userData);
List<Map<String, dynamic>> dataList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
List<Map<String, dynamic>> list = List<Map<String, dynamic>>.empty(growable: true);
for (var element in dataList) {
Map<String, dynamic> jso = element;
list.add(Map<String, dynamic>.from({
"errorCode": jso["group_topic_info_result_error_code"],
"errorMessage": jso["group_topic_info_result_error_message"],
"topicInfo": (await Tools.convert2DartTopicInfo(jso["group_topic_info_result_topic_info"])).toJson(),
}));
}
return V2TimCallback.fromJson({
"code": data['code'],
"desc": data['desc'],
"data": list,
});
}
}