createTopicInCommunity static method

Future<V2TimValueCallback<String>> createTopicInCommunity({
  1. required String groupID,
  2. required V2TimTopicInfo topicInfo,
})

Implementation

static Future<V2TimValueCallback<String>> createTopicInCommunity({
  required String groupID,
  required V2TimTopicInfo topicInfo,
}) async {
  String param = json.encode({
    "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,
  });
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  Pointer<Uint8> group_id = Tools.string2PointerInt8(groupID);

  Pointer<Uint8> json_topic_info = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMGroupCreateTopicInCommunity(group_id, json_topic_info, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<String>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    print(data);
    if (data["code"] == 0) {
      return V2TimValueCallback<String>.fromJson({"code": data["code"], "desc": data["desc"], "data": data["json_param"] ?? ""});
    } else {
      return V2TimValueCallback<String>.fromJson({"code": data["code"], "desc": data["desc"], "data": ""});
    }
  }
}