mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
fix remove chat profile img
This commit is contained in:
committed by
holger krekel
parent
275aa853f5
commit
0a8b187f80
@@ -898,9 +898,15 @@ pub unsafe extern "C" fn dc_set_chat_profile_image(
|
|||||||
|
|
||||||
let context = &*context;
|
let context = &*context;
|
||||||
|
|
||||||
chat::set_chat_profile_image(context, chat_id, as_str(image))
|
chat::set_chat_profile_image(context, chat_id, {
|
||||||
.map(|_| 1)
|
if image.is_null() {
|
||||||
.unwrap_or_log_default(context, "Failed to set profile image")
|
""
|
||||||
|
} else {
|
||||||
|
as_str(image)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|_| 1)
|
||||||
|
.unwrap_or_log_default(context, "Failed to set profile image")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
32
src/chat.rs
32
src/chat.rs
@@ -1653,34 +1653,34 @@ pub unsafe fn set_chat_profile_image(
|
|||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
ensure!(chat_id > DC_CHAT_ID_LAST_SPECIAL, "Invalid chat ID");
|
ensure!(chat_id > DC_CHAT_ID_LAST_SPECIAL, "Invalid chat ID");
|
||||||
|
|
||||||
let mut OK_TO_CONTINUE = true;
|
|
||||||
let mut success = false;
|
let mut success = false;
|
||||||
|
|
||||||
let mut chat = Chat::load_from_db(context, chat_id)?;
|
let mut chat = Chat::load_from_db(context, chat_id)?;
|
||||||
let mut msg = dc_msg_new_untyped(context);
|
let mut msg = dc_msg_new_untyped(context);
|
||||||
let mut new_image_rel = None;
|
let mut new_image_rel = None;
|
||||||
|
|
||||||
if real_group_exists(context, chat_id) {
|
(|| {
|
||||||
if !(is_contact_in_chat(context, chat_id, 1i32 as u32) == 1i32) {
|
if real_group_exists(context, chat_id) {
|
||||||
log_event!(
|
if !(is_contact_in_chat(context, chat_id, 1i32 as u32) == 1i32) {
|
||||||
context,
|
log_event!(
|
||||||
Event::ERROR_SELF_NOT_IN_GROUP,
|
context,
|
||||||
0,
|
Event::ERROR_SELF_NOT_IN_GROUP,
|
||||||
"Cannot set chat profile image; self not in group.",
|
0,
|
||||||
);
|
"Cannot set chat profile image; self not in group.",
|
||||||
} else {
|
);
|
||||||
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
|
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
|
||||||
|
return;
|
||||||
|
}
|
||||||
if !new_image.as_ref().is_empty() {
|
if !new_image.as_ref().is_empty() {
|
||||||
let mut img = new_image.as_ref().to_string();
|
let mut img = new_image.as_ref().to_string();
|
||||||
if !dc_make_rel_and_copy(context, &mut img) {
|
if !dc_make_rel_and_copy(context, &mut img) {
|
||||||
OK_TO_CONTINUE = false;
|
return;
|
||||||
}
|
}
|
||||||
new_image_rel = Some(img);
|
new_image_rel = Some(img);
|
||||||
} else {
|
} else {
|
||||||
OK_TO_CONTINUE = false;
|
new_image_rel = Some("".to_string());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if OK_TO_CONTINUE {
|
|
||||||
if let Some(ref new_image_rel) = new_image_rel {
|
if let Some(ref new_image_rel) = new_image_rel {
|
||||||
chat.param.set(Param::ProfileImage, new_image_rel);
|
chat.param.set(Param::ProfileImage, new_image_rel);
|
||||||
}
|
}
|
||||||
@@ -1716,7 +1716,7 @@ pub unsafe fn set_chat_profile_image(
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})();
|
||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
bail!("Failed to set profile image");
|
bail!("Failed to set profile image");
|
||||||
|
|||||||
Reference in New Issue
Block a user