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:
B. Petersen
2019-12-22 01:52:36 +01:00
committed by holger krekel
parent ce15ef2db9
commit 521a854635
2 changed files with 19 additions and 0 deletions

View File

@@ -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.