mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
add set_config_from_qr to jsonrpc
This commit is contained in:
@@ -7,6 +7,7 @@ use deltachat::{
|
|||||||
context::get_info,
|
context::get_info,
|
||||||
message::{Message, MsgId, Viewtype},
|
message::{Message, MsgId, Viewtype},
|
||||||
provider::get_provider_info,
|
provider::get_provider_info,
|
||||||
|
qr,
|
||||||
};
|
};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -185,6 +186,18 @@ impl CommandApi {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set configuration values from a QR code. (technically from the URI that is stored in the qrcode)
|
||||||
|
/// Before this function is called, dc_check_qr() should confirm the type of the
|
||||||
|
/// QR code is DC_QR_ACCOUNT or DC_QR_WEBRTC_INSTANCE.
|
||||||
|
///
|
||||||
|
/// Internally, the function will call dc_set_config() with the appropriate keys,
|
||||||
|
/// e.g. `addr` and `mail_pw` for DC_QR_ACCOUNT
|
||||||
|
/// or `webrtc_instance` for DC_QR_WEBRTC_INSTANCE.
|
||||||
|
async fn set_config_from_qr(&self, account_id: u32, qr_content: String) -> Result<()> {
|
||||||
|
let ctx = self.get_context(account_id).await?;
|
||||||
|
qr::set_config_from_qr(&ctx, &qr_content).await
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -109,6 +109,19 @@ export class RawClient {
|
|||||||
return (this._transport.request('batch_set_config', [accountId, config] as RPC.Params)) as Promise<null>;
|
return (this._transport.request('batch_set_config', [accountId, config] as RPC.Params)) as Promise<null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set configuration values from a QR code. (technically from the URI that is stored in the qrcode)
|
||||||
|
* Before this function is called, dc_check_qr() should confirm the type of the
|
||||||
|
* QR code is DC_QR_ACCOUNT or DC_QR_WEBRTC_INSTANCE.
|
||||||
|
*
|
||||||
|
* Internally, the function will call dc_set_config() with the appropriate keys,
|
||||||
|
* e.g. `addr` and `mail_pw` for DC_QR_ACCOUNT
|
||||||
|
* or `webrtc_instance` for DC_QR_WEBRTC_INSTANCE.
|
||||||
|
*/
|
||||||
|
public setConfigFromQr(accountId: T.U32, qrContent: string): Promise<null> {
|
||||||
|
return (this._transport.request('set_config_from_qr', [accountId, qrContent] as RPC.Params)) as Promise<null>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public getConfig(accountId: T.U32, key: string): Promise<(string|null)> {
|
public getConfig(accountId: T.U32, key: string): Promise<(string|null)> {
|
||||||
return (this._transport.request('get_config', [accountId, key] as RPC.Params)) as Promise<(string|null)>;
|
return (this._transport.request('get_config', [accountId, key] as RPC.Params)) as Promise<(string|null)>;
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ export type FullChat={"id":U32;"name":string;"is_protected":boolean;"profile_ima
|
|||||||
export type I32=number;
|
export type I32=number;
|
||||||
export type U64=number;
|
export type U64=number;
|
||||||
export type Message={"id":U32;"chat_id":U32;"from_id":U32;"quoted_text":(string|null);"quoted_message_id":(U32|null);"text":(string|null);"has_location":boolean;"has_html":boolean;"view_type":U32;"state":U32;"timestamp":I64;"sort_timestamp":I64;"received_timestamp":I64;"has_deviating_timestamp":boolean;"subject":string;"show_padlock":boolean;"is_setupmessage":boolean;"is_info":boolean;"is_forwarded":boolean;"duration":I32;"dimensions_height":I32;"dimensions_width":I32;"videochat_type":(U32|null);"videochat_url":(string|null);"override_sender_name":(string|null);"sender":Contact;"setup_code_begin":(string|null);"file":(string|null);"file_mime":(string|null);"file_bytes":U64;"file_name":(string|null);};
|
export type Message={"id":U32;"chat_id":U32;"from_id":U32;"quoted_text":(string|null);"quoted_message_id":(U32|null);"text":(string|null);"has_location":boolean;"has_html":boolean;"view_type":U32;"state":U32;"timestamp":I64;"sort_timestamp":I64;"received_timestamp":I64;"has_deviating_timestamp":boolean;"subject":string;"show_padlock":boolean;"is_setupmessage":boolean;"is_info":boolean;"is_forwarded":boolean;"duration":I32;"dimensions_height":I32;"dimensions_width":I32;"videochat_type":(U32|null);"videochat_url":(string|null);"override_sender_name":(string|null);"sender":Contact;"setup_code_begin":(string|null);"file":(string|null);"file_mime":(string|null);"file_bytes":U64;"file_name":(string|null);};
|
||||||
export type __AllTyps=[string,boolean,Record<string,string>,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record<string,string>,U32,string,(string|null),null,U32,Record<string,(string|null)>,null,U32,string,(string|null),U32,(string)[],Record<string,(string|null)>,U32,null,U32,null,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record<U32,ChatListItemFetchResult>,U32,U32,FullChat,U32,U32,null,U32,U32,null,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record<U32,Message>,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record<U32,Contact>,U32,string,U32,U32];
|
export type __AllTyps=[string,boolean,Record<string,string>,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record<string,string>,U32,string,(string|null),null,U32,Record<string,(string|null)>,null,U32,string,null,U32,string,(string|null),U32,(string)[],Record<string,(string|null)>,U32,null,U32,null,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record<U32,ChatListItemFetchResult>,U32,U32,FullChat,U32,U32,null,U32,U32,null,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record<U32,Message>,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record<U32,Contact>,U32,string,U32,U32];
|
||||||
|
|||||||
Reference in New Issue
Block a user