mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
add multi-device sync (#2669)
* add basic multi-device-sync functions * generate json * add context.parse_sync_items() * add context.execute_sync_items() * piggyback sync-commands message, add body for human-readable part * avoid double json renderings * mimeparser parses incoming .json sync-files * do not piggyback sync-files * execute sync items * return status of send_sync_msg() * send sync messages as multipart/report * add a per-item-timestamp and also allow adding other per-item-fields in the future * if the self-chat does not exist, create it blocked/hidden * create tokens closer to real qr-code needs * respect bcc_self setting, add test for that * sync qr code tokens after promoting groups * send sync-messages only if an experimental switch is set * trigger send_sync_msg() after sending messages and after creating/redraw/revive qr-code * add DC_STR_* constants to deltachat.h * adapt to refactored qr module as of #2729 * tweak test * use SendSyncMsgs config name instead of SendExperimentalSyncMsgs - we can remove or rename the config nevertheless, but have the option to keep it without renaming * tweak docs * remove currently unused effective timestamp calculation * clarify when send_sync_msg() is called * make sure, sync-messages are encrypted and are sent by SELF * tweak docs, fix typos
This commit is contained in:
@@ -30,6 +30,7 @@ use crate::token;
|
||||
mod bobstate;
|
||||
mod qrinvite;
|
||||
|
||||
use crate::token::Namespace;
|
||||
use bobstate::{BobHandshakeStage, BobState, BobStateHandle};
|
||||
use qrinvite::QrInvite;
|
||||
|
||||
@@ -171,8 +172,11 @@ pub async fn dc_get_securejoin_qr(context: &Context, group: Option<ChatId>) -> R
|
||||
|
||||
// invitenumber will be used to allow starting the handshake,
|
||||
// auth will be used to verify the fingerprint
|
||||
let invitenumber = token::lookup_or_new(context, token::Namespace::InviteNumber, group).await;
|
||||
let auth = token::lookup_or_new(context, token::Namespace::Auth, group).await;
|
||||
let sync_token = token::lookup(context, Namespace::InviteNumber, group)
|
||||
.await?
|
||||
.is_none();
|
||||
let invitenumber = token::lookup_or_new(context, Namespace::InviteNumber, group).await;
|
||||
let auth = token::lookup_or_new(context, Namespace::Auth, group).await;
|
||||
let self_addr = match context.get_config(Config::ConfiguredAddr).await {
|
||||
Ok(Some(addr)) => addr,
|
||||
Ok(None) => {
|
||||
@@ -208,7 +212,9 @@ pub async fn dc_get_securejoin_qr(context: &Context, group: Option<ChatId>) -> R
|
||||
let chat = Chat::load_from_db(context, group).await?;
|
||||
let group_name = chat.get_name();
|
||||
let group_name_urlencoded = utf8_percent_encode(group_name, NON_ALPHANUMERIC).to_string();
|
||||
|
||||
if sync_token {
|
||||
context.sync_qr_code_tokens(Some(chat.id)).await?;
|
||||
}
|
||||
format!(
|
||||
"OPENPGP4FPR:{}#a={}&g={}&x={}&i={}&s={}",
|
||||
fingerprint.hex(),
|
||||
@@ -220,6 +226,9 @@ pub async fn dc_get_securejoin_qr(context: &Context, group: Option<ChatId>) -> R
|
||||
)
|
||||
} else {
|
||||
// parameters used: a=n=i=s=
|
||||
if sync_token {
|
||||
context.sync_qr_code_tokens(None).await?;
|
||||
}
|
||||
format!(
|
||||
"OPENPGP4FPR:{}#a={}&n={}&i={}&s={}",
|
||||
fingerprint.hex(),
|
||||
|
||||
Reference in New Issue
Block a user