fix chat deletion

This commit is contained in:
dignifiedquire
2019-07-14 16:42:27 +02:00
parent 127e2193af
commit 6e73b3728d
2 changed files with 13 additions and 13 deletions

View File

@@ -470,7 +470,8 @@ pub unsafe extern "C" fn dc_delete_chat(context: *mut dc_context_t, chat_id: u32
assert!(!context.is_null()); assert!(!context.is_null());
let context = &*context; let context = &*context;
dc_chat::dc_delete_chat(context, chat_id) // TODO: update to indiciate public api success/failure of deletion
dc_chat::dc_delete_chat(context, chat_id);
} }
#[no_mangle] #[no_mangle]

View File

@@ -116,7 +116,6 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool {
unsafe { dc_chat_empty(chat) }; unsafe { dc_chat_empty(chat) };
let context = unsafe { (*chat).context }; let context = unsafe { (*chat).context };
info!(context, 0, "loading chat {}", chat_id);
let res = context.sql.query_row( let res = context.sql.query_row(
"SELECT c.id,c.type,c.name, c.grpid,c.param,c.archived, \ "SELECT c.id,c.type,c.name, c.grpid,c.param,c.archived, \
@@ -704,7 +703,6 @@ unsafe fn prepare_msg_raw(
"rfc724_mid", "rfc724_mid",
as_str(new_rfc724_mid), as_str(new_rfc724_mid),
); );
info!(context, 0, "got msg_id {}", msg_id);
} else { } else {
error!( error!(
context, context,
@@ -869,7 +867,6 @@ pub unsafe fn dc_send_msg<'a>(
if msg.is_null() { if msg.is_null() {
return 0; return 0;
} }
if (*msg).state != 18 { if (*msg).state != 18 {
if 0 == prepare_msg_common(context, chat_id, msg) { if 0 == prepare_msg_common(context, chat_id, msg) {
return 0; return 0;
@@ -1317,15 +1314,14 @@ pub fn dc_archive_chat(context: &Context, chat_id: u32, archive: libc::c_int) ->
true true
} }
pub fn dc_delete_chat(context: &Context, chat_id: u32) { pub fn dc_delete_chat(context: &Context, chat_id: u32) -> bool {
/* Up to 2017-11-02 deleting a group also implied leaving it, see above why we have changed this. */ /* Up to 2017-11-02 deleting a group also implied leaving it, see above why we have changed this. */
if chat_id > 9 { if chat_id <= 9 {
return; return false;
} }
let obj = unsafe { dc_chat_new(context) }; let obj = unsafe { dc_chat_new(context) };
if !dc_chat_load_from_db(obj, chat_id) { if !dc_chat_load_from_db(obj, chat_id) {
unsafe { dc_chat_unref(obj) }; return false;
return;
} }
unsafe { dc_chat_unref(obj) }; unsafe { dc_chat_unref(obj) };
@@ -1335,7 +1331,7 @@ pub fn dc_delete_chat(context: &Context, chat_id: u32) {
"DELETE FROM msgs_mdns WHERE msg_id IN (SELECT id FROM msgs WHERE chat_id=?);", "DELETE FROM msgs_mdns WHERE msg_id IN (SELECT id FROM msgs WHERE chat_id=?);",
params![chat_id as i32], params![chat_id as i32],
) { ) {
return; return false;
} }
if !sql::execute( if !sql::execute(
context, context,
@@ -1343,7 +1339,7 @@ pub fn dc_delete_chat(context: &Context, chat_id: u32) {
"DELETE FROM msgs WHERE chat_id=?;", "DELETE FROM msgs WHERE chat_id=?;",
params![chat_id as i32], params![chat_id as i32],
) { ) {
return; return false;
} }
if !sql::execute( if !sql::execute(
context, context,
@@ -1351,7 +1347,7 @@ pub fn dc_delete_chat(context: &Context, chat_id: u32) {
"DELETE FROM chats_contacts WHERE chat_id=?;", "DELETE FROM chats_contacts WHERE chat_id=?;",
params![chat_id as i32], params![chat_id as i32],
) { ) {
return; return false;
} }
if !sql::execute( if !sql::execute(
context, context,
@@ -1359,12 +1355,15 @@ pub fn dc_delete_chat(context: &Context, chat_id: u32) {
"DELETE FROM chats WHERE id=?;", "DELETE FROM chats WHERE id=?;",
params![chat_id as i32], params![chat_id as i32],
) { ) {
return; return false;
} }
context.call_cb(Event::MSGS_CHANGED, 0 as uintptr_t, 0 as uintptr_t); context.call_cb(Event::MSGS_CHANGED, 0 as uintptr_t, 0 as uintptr_t);
dc_job_kill_action(context, 105); dc_job_kill_action(context, 105);
unsafe { dc_job_add(context, 105, 0, 0 as *const libc::c_char, 10) }; unsafe { dc_job_add(context, 105, 0, 0 as *const libc::c_char, 10) };
true
} }
pub fn dc_get_chat_contacts(context: &Context, chat_id: u32) -> *mut dc_array_t { pub fn dc_get_chat_contacts(context: &Context, chat_id: u32) -> *mut dc_array_t {