mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 02:16:29 +03:00
delete and reset device-messages on import; this avoids wrong information in the device chat and allows adding correct information again
This commit is contained in:
committed by
holger krekel
parent
ce15ef2db9
commit
521a854635
16
src/chat.rs
16
src/chat.rs
@@ -2197,6 +2197,22 @@ pub fn was_device_msg_ever_added(context: &Context, label: &str) -> Result<bool,
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
// needed on device-switches during export/import;
|
||||
// - deletion in `msgs` with `DC_CONTACT_ID_DEVICE` makes sure,
|
||||
// no wrong information are shown in the device chat
|
||||
// - deletion in `devmsglabels` makes sure,
|
||||
// deleted messages are resetted and useful messages can be added again
|
||||
pub fn delete_and_reset_all_device_msgs(context: &Context) -> Result<(), Error> {
|
||||
context.sql.execute(
|
||||
"DELETE FROM msgs WHERE from_id=?;",
|
||||
params![DC_CONTACT_ID_DEVICE],
|
||||
)?;
|
||||
context
|
||||
.sql
|
||||
.execute("DELETE FROM devmsglabels;", params![])?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Adds an informational message to chat.
|
||||
///
|
||||
/// For example, it can be a message showing that a member was added to a group.
|
||||
|
||||
@@ -8,6 +8,7 @@ use rand::{thread_rng, Rng};
|
||||
|
||||
use crate::blob::BlobObject;
|
||||
use crate::chat;
|
||||
use crate::chat::delete_and_reset_all_device_msgs;
|
||||
use crate::config::Config;
|
||||
use crate::configure::*;
|
||||
use crate::constants::*;
|
||||
@@ -441,6 +442,8 @@ fn import_backup(context: &Context, backup_to_import: impl AsRef<Path>) -> Resul
|
||||
"could not re-open db"
|
||||
);
|
||||
|
||||
delete_and_reset_all_device_msgs(&context)?;
|
||||
|
||||
let total_files_cnt = context
|
||||
.sql
|
||||
.query_get_value::<_, isize>(context, "SELECT COUNT(*) FROM backup_blobs;", params![])
|
||||
|
||||
Reference in New Issue
Block a user