Refactor dc_set_chat_profile_image, make it a bit rustier and fix bug of not being able to

unset profile_image
This commit is contained in:
jikstra
2019-08-15 17:53:04 +02:00
parent 18b70bff0e
commit f101439175
3 changed files with 52 additions and 77 deletions

View File

@@ -810,15 +810,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
ensure!(!sel_chat.is_null(), "No chat selected.");
ensure!(!arg1.is_empty(), "Argument <image> missing.");
if 0 != dc_set_chat_profile_image(
context,
dc_chat_get_id(sel_chat),
if !arg1.is_empty() {
arg1_c
} else {
std::ptr::null_mut()
},
) {
if dc_set_chat_profile_image(context, dc_chat_get_id(sel_chat), arg1) {
println!("Chat image set");
} else {
bail!("Failed to set chat image");