mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 06:46:32 +03:00
docs: improve JSON-RPC API documentation
This commit is contained in:
@@ -153,12 +153,12 @@ impl CommandApi {
|
|||||||
// Misc top level functions
|
// Misc top level functions
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|
||||||
/// Check if an email address is valid.
|
/// Checks if an email address is valid.
|
||||||
async fn check_email_validity(&self, email: String) -> bool {
|
async fn check_email_validity(&self, email: String) -> bool {
|
||||||
may_be_valid_addr(&email)
|
may_be_valid_addr(&email)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get general system info.
|
/// Returns general system info.
|
||||||
async fn get_system_info(&self) -> BTreeMap<&'static str, String> {
|
async fn get_system_info(&self) -> BTreeMap<&'static str, String> {
|
||||||
get_info()
|
get_info()
|
||||||
}
|
}
|
||||||
@@ -219,11 +219,13 @@ impl CommandApi {
|
|||||||
Ok(accounts)
|
Ok(accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Starts background tasks for all accounts.
|
||||||
async fn start_io_for_all_accounts(&self) -> Result<()> {
|
async fn start_io_for_all_accounts(&self) -> Result<()> {
|
||||||
self.accounts.read().await.start_io().await;
|
self.accounts.read().await.start_io().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stops background tasks for all accounts.
|
||||||
async fn stop_io_for_all_accounts(&self) -> Result<()> {
|
async fn stop_io_for_all_accounts(&self) -> Result<()> {
|
||||||
self.accounts.read().await.stop_io().await;
|
self.accounts.read().await.stop_io().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -233,14 +235,16 @@ impl CommandApi {
|
|||||||
// Methods that work on individual accounts
|
// Methods that work on individual accounts
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
|
|
||||||
async fn start_io(&self, id: u32) -> Result<()> {
|
/// Starts background tasks for a single account.
|
||||||
let ctx = self.get_context(id).await?;
|
async fn start_io(&self, account_id: u32) -> Result<()> {
|
||||||
|
let ctx = self.get_context(account_id).await?;
|
||||||
ctx.start_io().await;
|
ctx.start_io().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn stop_io(&self, id: u32) -> Result<()> {
|
/// Stops background tasks for a single account.
|
||||||
let ctx = self.get_context(id).await?;
|
async fn stop_io(&self, account_id: u32) -> Result<()> {
|
||||||
|
let ctx = self.get_context(account_id).await?;
|
||||||
ctx.stop_io().await;
|
ctx.stop_io().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -307,11 +311,13 @@ impl CommandApi {
|
|||||||
ctx.get_info().await
|
ctx.get_info().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the given configuration key.
|
||||||
async fn set_config(&self, account_id: u32, key: String, value: Option<String>) -> Result<()> {
|
async fn set_config(&self, account_id: u32, key: String, value: Option<String>) -> Result<()> {
|
||||||
let ctx = self.get_context(account_id).await?;
|
let ctx = self.get_context(account_id).await?;
|
||||||
set_config(&ctx, &key, value.as_deref()).await
|
set_config(&ctx, &key, value.as_deref()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Updates a batch of configuration values.
|
||||||
async fn batch_set_config(
|
async fn batch_set_config(
|
||||||
&self,
|
&self,
|
||||||
account_id: u32,
|
account_id: u32,
|
||||||
@@ -343,6 +349,7 @@ impl CommandApi {
|
|||||||
Ok(qr_object)
|
Ok(qr_object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns configuration value for the given key.
|
||||||
async fn get_config(&self, account_id: u32, key: String) -> Result<Option<String>> {
|
async fn get_config(&self, account_id: u32, key: String) -> Result<Option<String>> {
|
||||||
let ctx = self.get_context(account_id).await?;
|
let ctx = self.get_context(account_id).await?;
|
||||||
get_config(&ctx, &key).await
|
get_config(&ctx, &key).await
|
||||||
@@ -1863,7 +1870,7 @@ impl CommandApi {
|
|||||||
.context("path conversion to string failed")
|
.context("path conversion to string failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// save a sticker to a collection/folder in the account's sticker folder
|
/// Saves a sticker to a collection/folder in the account's sticker folder.
|
||||||
async fn misc_save_sticker(
|
async fn misc_save_sticker(
|
||||||
&self,
|
&self,
|
||||||
account_id: u32,
|
account_id: u32,
|
||||||
|
|||||||
Reference in New Issue
Block a user