From 517cb821fb01c539c31ea8e92e85ddb48aebeade Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Fri, 17 May 2024 21:33:59 +0200 Subject: [PATCH] jsonrpc: add api `migrate_account` and `get_blob_dir` (#5584) closes #5533 adds the functions that were still missing for migration to jsonrpc (the ones that the cffi already had, so just should be quick to review ;) --- deltachat-jsonrpc/src/api.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index d1cdc9211..9855df949 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -185,6 +185,16 @@ impl CommandApi { self.accounts.write().await.add_account().await } + /// Imports/migrated an existing account from a database path into this account manager. + /// Returns the ID of new account. + async fn migrate_account(&self, path_to_db: String) -> Result { + self.accounts + .write() + .await + .migrate_account(std::path::PathBuf::from(path_to_db)) + .await + } + async fn remove_account(&self, account_id: u32) -> Result<()> { self.accounts .write() @@ -329,6 +339,11 @@ impl CommandApi { ctx.get_info().await } + async fn get_blob_dir(&self, account_id: u32) -> Result> { + let ctx = self.get_context(account_id).await?; + Ok(ctx.get_blobdir().to_str().map(|s| s.to_owned())) + } + async fn draft_self_report(&self, account_id: u32) -> Result { let ctx = self.get_context(account_id).await?; Ok(ctx.draft_self_report().await?.to_u32())