Impl GetUserInfo
This commit is contained in:
parent
54ead79f4d
commit
b19f41b8cf
@ -87,6 +87,28 @@ bool func_get_self_wxid(uint8_t *out, size_t *len)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool func_get_user_info(uint8_t *out, size_t *len)
|
||||
{
|
||||
Response rsp = Response_init_default;
|
||||
rsp.func = Functions_FUNC_GET_USER_INFO;
|
||||
rsp.which_msg = Response_ui_tag;
|
||||
|
||||
UserInfo_t ui = GetUserInfo();
|
||||
rsp.msg.ui.wxid = (char *)ui.wxid.c_str();
|
||||
rsp.msg.ui.name = (char *)ui.name.c_str();
|
||||
rsp.msg.ui.mobile = (char *)ui.mobile.c_str();
|
||||
rsp.msg.ui.home = (char *)ui.home.c_str();
|
||||
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
|
||||
if (!pb_encode(&stream, Response_fields, &rsp)) {
|
||||
LOG_ERROR("Encoding failed: {}", PB_GET_ERROR(&stream));
|
||||
return false;
|
||||
}
|
||||
*len = stream.bytes_written;
|
||||
|
||||
return true;
|
||||
}
|
||||
#if 0
|
||||
bool func_get_msg_types(uint8_t *out, size_t *len)
|
||||
{
|
||||
@ -168,28 +190,6 @@ bool func_get_db_tables(char *db, uint8_t *out, size_t *len)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool func_get_user_info(uint8_t *out, size_t *len)
|
||||
{
|
||||
Response rsp = Response_init_default;
|
||||
rsp.func = Functions_FUNC_GET_USER_INFO;
|
||||
rsp.which_msg = Response_ui_tag;
|
||||
|
||||
UserInfo_t ui = GetUserInfo();
|
||||
rsp.msg.ui.wxid = (char *)ui.wxid.c_str();
|
||||
rsp.msg.ui.name = (char *)ui.name.c_str();
|
||||
rsp.msg.ui.mobile = (char *)ui.mobile.c_str();
|
||||
rsp.msg.ui.home = (char *)ui.home.c_str();
|
||||
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
|
||||
if (!pb_encode(&stream, Response_fields, &rsp)) {
|
||||
LOG_ERROR("Encoding failed: {}", PB_GET_ERROR(&stream));
|
||||
return false;
|
||||
}
|
||||
*len = stream.bytes_written;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool func_get_audio_msg(uint64_t id, char *dir, uint8_t *out, size_t *len)
|
||||
{
|
||||
Response rsp = Response_init_default;
|
||||
@ -858,6 +858,10 @@ static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len
|
||||
ret = func_get_self_wxid(out, out_len);
|
||||
break;
|
||||
}
|
||||
case Functions_FUNC_GET_USER_INFO: {
|
||||
ret = func_get_user_info(out, out_len);
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
case Functions_FUNC_GET_MSG_TYPES: {
|
||||
ret = func_get_msg_types(out, out_len);
|
||||
@ -875,10 +879,6 @@ static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len
|
||||
ret = func_get_db_tables(req.msg.str, out, out_len);
|
||||
break;
|
||||
}
|
||||
case Functions_FUNC_GET_USER_INFO: {
|
||||
ret = func_get_user_info(out, out_len);
|
||||
break;
|
||||
}
|
||||
case Functions_FUNC_GET_AUDIO_MSG: {
|
||||
ret = func_get_audio_msg(req.msg.am.id, req.msg.am.dir, out, out_len);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user