Skip to content

Commit 1113e0d

Browse files
committed
feat: add device message about legacy mvbox_move
1 parent 2c3f754 commit 1113e0d

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/sql.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ 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;
1213
use crate::config::Config;
1314
use crate::constants::DC_CHAT_ID_TRASH;
1415
use crate::context::Context;
@@ -17,11 +18,13 @@ use crate::ephemeral::start_ephemeral_timers;
1718
use crate::imex::BLOBS_BACKUP_NAME;
1819
use crate::location::delete_orphaned_poi_locations;
1920
use crate::log::{LogExt, warn};
21+
use crate::message::Message;
2022
use crate::message::MsgId;
2123
use crate::net::dns::prune_dns_cache;
2224
use crate::net::http::http_cache_cleanup;
2325
use crate::net::prune_connection_history;
2426
use crate::param::{Param, Params};
27+
use crate::stock_str;
2528
use crate::tools::{SystemTime, Time, delete_file, time, time_elapsed};
2629

2730
/// Extension to [`rusqlite::ToSql`] trait
@@ -865,6 +868,12 @@ pub async fn housekeeping(context: &Context) -> Result<()> {
865868
);
866869
}
867870

871+
maybe_add_mvbox_move_deprecation_message(context)
872+
.await
873+
.context("maybe_add_mvbox_move_deprecation_message")
874+
.log_err(context)
875+
.ok();
876+
868877
if let Err(err) = incremental_vacuum(context).await {
869878
warn!(context, "Failed to run incremental vacuum: {err:#}.");
870879
}
@@ -924,6 +933,18 @@ pub async fn housekeeping(context: &Context) -> Result<()> {
924933
Ok(())
925934
}
926935

936+
/// Adds device message about `mvbox_move` config deprecation
937+
/// if the user has it enabled.
938+
async fn maybe_add_mvbox_move_deprecation_message(context: &Context) -> Result<()> {
939+
if !context.get_config_bool(Config::OnlyFetchMvbox)
940+
&& context.get_config_bool(Config::MvboxMove).await?
941+
{
942+
let mut msg = Message::new_text(stock_str::mvbox_move_deprecation(context).await);
943+
add_device_msg(context, Some("mvbox_move_deprecation"), Some(&mut msg)).await?;
944+
}
945+
Ok(())
946+
}
947+
927948
/// Get the value of a column `idx` of the `row` as `Vec<u8>`.
928949
pub fn row_get_vec(row: &Row, idx: usize) -> rusqlite::Result<Vec<u8>> {
929950
row.get(idx).or_else(|err| match row.get_ref(idx)? {

src/stock_str.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ https://delta.chat/donate"))]
412412

413413
#[strum(props(fallback = "Messages in this chat use classic email and are not encrypted."))]
414414
ChatUnencryptedExplanation = 230,
415+
416+
#[strum(props(
417+
fallback = "You are using the legacy option \"Settings → Advanced → Move automatically to DeltaChat Folder\".\n\nThis option will be removed in a few weeks and you should disable it already today.\n\nIf having chat messages mixed into your inbox is a problem, see https://delta.chat/legacy-move"
418+
))]
419+
MvboxMoveDeprecation = 231,
415420
}
416421

417422
impl StockMessage {
@@ -1223,6 +1228,11 @@ pub(crate) async fn chat_unencrypted_explanation(context: &Context) -> String {
12231228
translated(context, StockMessage::ChatUnencryptedExplanation).await
12241229
}
12251230

1231+
/// Stock string: `You are using the legacy option "Move automatically to DeltaChat Folder`…
1232+
pub(crate) async fn mvbox_move_deprecation(context: &Context) -> String {
1233+
translated(context, StockMessage::MvboxMoveDeprecation).await
1234+
}
1235+
12261236
impl Viewtype {
12271237
/// returns Localized name for message viewtype
12281238
pub async fn to_locale_string(&self, context: &Context) -> String {

0 commit comments

Comments
 (0)