mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
I.e. treat `DeleteServerAfter == None` as "delete at once". But when a backup is exported, set `DeleteServerAfter` to 0 so that the server decides when to delete messages, in order not to break the multi-device case. Even if a backup is not aimed for deploying more devices, `DeleteServerAfter` must be set to 0, otherwise the backup is half-useful because after a restoration the user wouldn't see new messages deleted by the device after the backup was done. But if the user explicitly set `DeleteServerAfter`, don't change it when exporting a backup. Anyway even for non-chatmail case the app should warn the user before a backup export if they have `DeleteServerAfter` enabled. Also do the same after a backup import. While this isn't reliable as we can crash in between, this is a problem only for old backups, new backups already have `DeleteServerAfter` set if necessary. --------- Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
@@ -174,12 +174,12 @@ pub enum Config {
|
||||
/// Timer in seconds after which the message is deleted from the
|
||||
/// server.
|
||||
///
|
||||
/// Equals to 0 by default, which means the message is never
|
||||
/// deleted.
|
||||
/// 0 means messages are never deleted by Delta Chat.
|
||||
///
|
||||
/// Value 1 is treated as "delete at once": messages are deleted
|
||||
/// immediately, without moving to DeltaChat folder.
|
||||
#[strum(props(default = "0"))]
|
||||
///
|
||||
/// Default is 1 for chatmail accounts before a backup export, 0 otherwise.
|
||||
DeleteServerAfter,
|
||||
|
||||
/// Timer in seconds after which the message is deleted from the
|
||||
@@ -470,10 +470,15 @@ impl Context {
|
||||
}
|
||||
|
||||
// Default values
|
||||
match key {
|
||||
Config::ConfiguredInboxFolder => Ok(Some("INBOX".to_owned())),
|
||||
_ => Ok(key.get_str("default").map(|s| s.to_string())),
|
||||
}
|
||||
let val = match key {
|
||||
Config::ConfiguredInboxFolder => Some("INBOX"),
|
||||
Config::DeleteServerAfter => match Box::pin(self.is_chatmail()).await? {
|
||||
false => Some("0"),
|
||||
true => Some("1"),
|
||||
},
|
||||
_ => key.get_str("default"),
|
||||
};
|
||||
Ok(val.map(|s| s.to_string()))
|
||||
}
|
||||
|
||||
/// Returns Some(T) if a value for the given key exists and was successfully parsed.
|
||||
@@ -555,11 +560,16 @@ impl Context {
|
||||
/// `None` means never delete the message, `Some(0)` means delete
|
||||
/// at once, `Some(x)` means delete after `x` seconds.
|
||||
pub async fn get_config_delete_server_after(&self) -> Result<Option<i64>> {
|
||||
match self.get_config_int(Config::DeleteServerAfter).await? {
|
||||
0 => Ok(None),
|
||||
1 => Ok(Some(0)),
|
||||
x => Ok(Some(i64::from(x))),
|
||||
}
|
||||
let val = match self
|
||||
.get_config_parsed::<i64>(Config::DeleteServerAfter)
|
||||
.await?
|
||||
.unwrap_or(0)
|
||||
{
|
||||
0 => None,
|
||||
1 => Some(0),
|
||||
x => Some(x),
|
||||
};
|
||||
Ok(val)
|
||||
}
|
||||
|
||||
/// Gets the configured provider, as saved in the `configured_provider` value.
|
||||
|
||||
Reference in New Issue
Block a user