Skip to content

Commit db066ca

Browse files
committed
refactor: remove update_icons and disable_server_delete migrations
1 parent d889197 commit db066ca

File tree

5 files changed

+6
-54
lines changed

5 files changed

+6
-54
lines changed

deltachat-ffi/deltachat.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7215,11 +7215,6 @@ void dc_event_unref(dc_event_t* event);
72157215
/// Used as device message text.
72167216
#define DC_STR_SELF_DELETED_MSG_BODY 91
72177217

7218-
/// "'Delete messages from server' turned off as now all folders are affected."
7219-
///
7220-
/// Used as device message text.
7221-
#define DC_STR_SERVER_TURNED_OFF 92
7222-
72237218
/// "Message deletion timer is set to %1$s minutes."
72247219
///
72257220
/// Used in status messages.

src/sql.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rusqlite::{Connection, OpenFlags, Row, config::DbConfig, types::ValueRef};
99
use tokio::sync::RwLock;
1010

1111
use crate::blob::BlobObject;
12-
use crate::chat::add_device_msg;
1312
use crate::config::Config;
1413
use crate::constants::DC_CHAT_ID_TRASH;
1514
use crate::context::Context;
@@ -18,12 +17,11 @@ use crate::ephemeral::start_ephemeral_timers;
1817
use crate::imex::BLOBS_BACKUP_NAME;
1918
use crate::location::delete_orphaned_poi_locations;
2019
use crate::log::{LogExt, warn};
21-
use crate::message::{Message, MsgId};
20+
use crate::message::MsgId;
2221
use crate::net::dns::prune_dns_cache;
2322
use crate::net::http::http_cache_cleanup;
2423
use crate::net::prune_connection_history;
2524
use crate::param::{Param, Params};
26-
use crate::stock_str;
2725
use crate::tools::{SystemTime, Time, delete_file, time, time_elapsed};
2826

2927
/// Extension to [`rusqlite::ToSql`] trait
@@ -216,26 +214,13 @@ impl Sql {
216214
// this should be done before updates that use high-level objects that
217215
// rely themselves on the low-level structure.
218216

219-
// `update_icons` is not used anymore, since it's not necessary anymore to "update" icons:
220-
let (_update_icons, disable_server_delete, recode_avatar) = migrations::run(context, self)
217+
let recode_avatar = migrations::run(context, self)
221218
.await
222219
.context("failed to run migrations")?;
223220

224221
// (2) updates that require high-level objects
225222
// the structure is complete now and all objects are usable
226223

227-
if disable_server_delete {
228-
// We now always watch all folders and delete messages there if delete_server is enabled.
229-
// So, for people who have delete_server enabled, disable it and add a hint to the devicechat:
230-
if context.get_config_delete_server_after().await?.is_some() {
231-
let mut msg = Message::new_text(stock_str::delete_server_turned_off(context).await);
232-
add_device_msg(context, None, Some(&mut msg)).await?;
233-
context
234-
.set_config_internal(Config::DeleteServerAfter, Some("0"))
235-
.await?;
236-
}
237-
}
238-
239224
if recode_avatar && let Some(avatar) = context.get_config(Config::Selfavatar).await? {
240225
let mut blob = BlobObject::from_path(context, Path::new(&avatar))?;
241226
match blob.recode_to_avatar_size(context).await {

src/sql/migrations.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tokio::task_local! {
3131
static STOP_MIGRATIONS_AT: i32;
3232
}
3333

34-
pub async fn run(context: &Context, sql: &Sql) -> Result<(bool, bool, bool)> {
34+
pub async fn run(context: &Context, sql: &Sql) -> Result<bool> {
3535
let mut exists_before_update = false;
3636
let mut dbversion_before_update = DBVERSION;
3737

@@ -68,8 +68,6 @@ pub async fn run(context: &Context, sql: &Sql) -> Result<(bool, bool, bool)> {
6868
}
6969

7070
let dbversion = dbversion_before_update;
71-
let mut update_icons = !exists_before_update;
72-
let mut disable_server_delete = false;
7371
let mut recode_avatar = false;
7472

7573
if dbversion < 1 {
@@ -299,7 +297,6 @@ CREATE INDEX devmsglabels_index1 ON devmsglabels (label);"#, 59)
299297
61,
300298
)
301299
.await?;
302-
update_icons = true;
303300
}
304301
if dbversion < 62 {
305302
sql.execute_migration(
@@ -327,7 +324,6 @@ ALTER TABLE msgs ADD COLUMN ephemeral_timestamp INTEGER DEFAULT 0;"#,
327324
.await?;
328325
}
329326
if dbversion < 66 {
330-
update_icons = true;
331327
sql.set_db_version(66).await?;
332328
}
333329
if dbversion < 67 {
@@ -445,17 +441,6 @@ CREATE TABLE imap_sync (folder TEXT PRIMARY KEY, uidvalidity INTEGER DEFAULT 0,
445441
}
446442
}
447443
}
448-
if exists_before_update {
449-
disable_server_delete = true;
450-
451-
// Don't disable server delete if it was on by default (Nauta):
452-
if let Some(provider) = context.get_configured_provider().await?
453-
&& let Some(defaults) = &provider.config_defaults
454-
&& defaults.iter().any(|d| d.key == Config::DeleteServerAfter)
455-
{
456-
disable_server_delete = false;
457-
}
458-
}
459444
sql.set_db_version(73).await?;
460445
}
461446
if dbversion < 74 {
@@ -1468,7 +1453,7 @@ CREATE INDEX imap_sync_index ON imap_sync(transport_id, folder);
14681453
}
14691454
info!(context, "Database version: v{new_version}.");
14701455

1471-
Ok((update_icons, disable_server_delete, recode_avatar))
1456+
Ok(recode_avatar)
14721457
}
14731458

14741459
fn migrate_key_contacts(

src/sql/sql_tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::*;
2+
use crate::message::Message;
23
use crate::{EventType, test_utils::TestContext};
34

45
#[test]
@@ -179,9 +180,7 @@ async fn test_migration_flags() -> Result<()> {
179180
// as migrations::run() was already executed on context creation,
180181
// another call should not result in any action needed.
181182
// this test catches some bugs where dbversion was forgotten to be persisted.
182-
let (update_icons, disable_server_delete, recode_avatar) = migrations::run(&t, &t.sql).await?;
183-
assert!(!update_icons);
184-
assert!(!disable_server_delete);
183+
let recode_avatar = migrations::run(&t, &t.sql).await?;
185184
assert!(!recode_avatar);
186185

187186
info!(&t, "test_migration_flags: XXX END MARKER");

src/stock_str.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,6 @@ pub enum StockMessage {
155155
To use the \"Saved messages\" feature again, create a new chat with yourself."))]
156156
SelfDeletedMsgBody = 91,
157157

158-
#[strum(props(
159-
fallback = "⚠️ The \"Delete messages from server\" feature now also deletes messages in folders other than Inbox, DeltaChat and Sent.\n\n\
160-
ℹ️ To avoid accidentally deleting messages, we turned it off for you. Please turn it on again at \
161-
Settings → \"Chats and Media\"\"Delete messages from server\" to continue using it."
162-
))]
163-
DeleteServerTurnedOff = 92,
164-
165158
#[strum(props(fallback = "Forwarded"))]
166159
Forwarded = 97,
167160

@@ -1041,11 +1034,6 @@ pub(crate) async fn self_deleted_msg_body(context: &Context) -> String {
10411034
translated(context, StockMessage::SelfDeletedMsgBody).await
10421035
}
10431036

1044-
/// Stock string: `⚠️ The "Delete messages from server" feature now also...`.
1045-
pub(crate) async fn delete_server_turned_off(context: &Context) -> String {
1046-
translated(context, StockMessage::DeleteServerTurnedOff).await
1047-
}
1048-
10491037
/// Stock string: `Message deletion timer is set to %1$s minutes.`.
10501038
pub(crate) async fn msg_ephemeral_timer_minutes(
10511039
context: &Context,

0 commit comments

Comments
 (0)