diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 6dec8e23a..c042ded02 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -848,7 +848,7 @@ pub unsafe extern "C" fn dc_add_contact_to_chat( let context = &*context; - chat::add_contact_to_chat(context, chat_id, contact_id) + chat::add_contact_to_chat(context, chat_id, contact_id) as libc::c_int } #[no_mangle] diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index b88791e9b..8f6ea5a5e 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -705,7 +705,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E ensure!(!arg1.is_empty(), "Argument missing."); let contact_id_0: libc::c_int = arg1.parse()?; - if 0 != chat::add_contact_to_chat( + if chat::add_contact_to_chat( context, sel_chat.as_ref().unwrap().get_id(), contact_id_0 as uint32_t, diff --git a/src/chat.rs b/src/chat.rs index ce9fb410b..243f1f88f 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1297,24 +1297,23 @@ pub fn add_to_chat_contacts_table(context: &Context, chat_id: u32, contact_id: u .is_ok() } -pub unsafe fn add_contact_to_chat(context: &Context, chat_id: u32, contact_id: u32) -> libc::c_int { +pub unsafe fn add_contact_to_chat(context: &Context, chat_id: u32, contact_id: u32) -> bool { add_contact_to_chat_ex(context, chat_id, contact_id, 0) } -// TODO should return bool /rtn #[allow(non_snake_case)] pub fn add_contact_to_chat_ex( context: &Context, chat_id: u32, contact_id: u32, flags: libc::c_int, -) -> libc::c_int { +) -> bool { let mut OK_TO_CONTINUE = true; - let mut success: libc::c_int = 0; + let mut success = false; let contact = Contact::get_by_id(context, contact_id); if contact.is_err() || chat_id <= DC_CHAT_ID_LAST_SPECIAL { - return 0; + return false; } let mut msg = dc_msg_new_untyped(); @@ -1351,7 +1350,7 @@ pub fn add_contact_to_chat_ex( if 0 != is_contact_in_chat(context, chat_id, contact_id) { if 0 == flags & 0x1 { - success = 1; + success = true; OK_TO_CONTINUE = false; } } else { @@ -1391,7 +1390,7 @@ pub fn add_contact_to_chat_ex( ); } context.call_cb(Event::MSGS_CHANGED, chat_id as uintptr_t, 0 as uintptr_t); - success = 1; + success = true; } } }