mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
Improve error handling in dc_send_text_msg()
Previously, dc_send_text_msg() silently returned 0 in case of incorrect input. This way "send" command in repl reported "Sending failed" without any clue what exactly went wrong.
This commit is contained in:
committed by
holger krekel
parent
cb75ac3842
commit
72ad8b5199
@@ -961,12 +961,22 @@ pub unsafe fn dc_send_text_msg(
|
|||||||
chat_id: uint32_t,
|
chat_id: uint32_t,
|
||||||
text_to_send: *const libc::c_char,
|
text_to_send: *const libc::c_char,
|
||||||
) -> uint32_t {
|
) -> uint32_t {
|
||||||
let mut msg = dc_msg_new(context, 10);
|
if chat_id <= 9 {
|
||||||
let mut ret = 0;
|
warn!(
|
||||||
if !(chat_id <= 9 || text_to_send.is_null()) {
|
context,
|
||||||
(*msg).text = dc_strdup(text_to_send);
|
0, "dc_send_text_msg: bad chat_id = {} <= 9", chat_id
|
||||||
ret = dc_send_msg(context, chat_id, msg);
|
);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if text_to_send.is_null() {
|
||||||
|
warn!(context, 0, "dc_send_text_msg: text_to_send is emtpy");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut msg = dc_msg_new(context, 10);
|
||||||
|
(*msg).text = dc_strdup(text_to_send);
|
||||||
|
let ret = dc_send_msg(context, chat_id, msg);
|
||||||
dc_msg_unref(msg);
|
dc_msg_unref(msg);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user