diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 3bf828850..a1cc8699a 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -571,6 +571,30 @@ impl CommandApi { ctx.delete_transport(&addr).await } + // TODO not sure if that's a good API design, + // but I'm also not sure about an alternative - Adding to EnteredLoginParam? + async fn set_transport_unpublished( + &self, + account_id: u32, + addr: String, + unpublished: bool, + ) -> Result<()> { + let ctx = self.get_context(account_id).await?; + ctx.set_transport_unpublished(addr, unpublished).await + } + + // TODO not sure if that's a good API design, + // but I'm also not sure about an alternative - Adding to EnteredLoginParam? + async fn get_transport_unpublished( + &self, + account_id: u32, + addr: String, + unpublished: bool, + ) -> Result<()> { + let ctx = self.get_context(account_id).await?; + ctx.get_transport_unpublished(addr, unpublished).await + } + /// Signal an ongoing process to stop. async fn stop_ongoing_process(&self, account_id: u32) -> Result<()> { let ctx = self.get_context(account_id).await?; diff --git a/src/config.rs b/src/config.rs index f524efb64..c842b41ba 100644 --- a/src/config.rs +++ b/src/config.rs @@ -974,7 +974,23 @@ impl Context { .await } + /// Returns all published self addresses, newest first. + /// See TODO API + pub(crate) async fn get_published_self_addrs(&self) -> Result> { + self.sql + .query_map_vec( + "SELECT addr FROM transports WHERE published=1 ORDER BY add_timestamp DESC", + (), + |row| { + let addr: String = row.get(0)?; + Ok(addr) + }, + ) + .await + } + /// Returns all secondary self addresses. + // TODO this function might be refactored out pub(crate) async fn get_secondary_self_addrs(&self) -> Result> { self.sql.query_map_vec("SELECT addr FROM transports WHERE addr NOT IN (SELECT value FROM config WHERE keyname='configured_addr')", (), |row| { let addr: String = row.get(0)?; @@ -982,6 +998,23 @@ impl Context { }).await } + /// Returns all published secondary self addresses. + /// See TODO API + pub(crate) async fn get_published_secondary_self_addrs(&self) -> Result> { + self.sql + .query_map_vec( + "SELECT addr FROM transports + WHERE published=1 + AND addr NOT IN (SELECT value FROM config WHERE keyname='configured_addr')", + (), + |row| { + let addr: String = row.get(0)?; + Ok(addr) + }, + ) + .await + } + /// Returns the primary self address. /// Returns an error if no self addr is configured. pub async fn get_primary_self_addr(&self) -> Result { diff --git a/src/key.rs b/src/key.rs index 101c03518..3e50f922d 100644 --- a/src/key.rs +++ b/src/key.rs @@ -296,7 +296,7 @@ pub(crate) async fn load_self_public_key_opt(context: &Context) -> Result