Merge remote-tracking branch 'origin/main' into hoc/channels-encryption-only-qrcodes

This commit is contained in:
Hocuri
2025-09-09 19:16:50 +02:00
6 changed files with 110 additions and 15 deletions

View File

@@ -32,16 +32,30 @@ use qrinvite::QrInvite;
use crate::token::Namespace;
fn inviter_progress(context: &Context, contact_id: ContactId, progress: usize) {
fn inviter_progress(
context: &Context,
contact_id: ContactId,
step: &str,
progress: usize,
) -> Result<()> {
logged_debug_assert!(
context,
progress <= 1000,
"inviter_progress: contact {contact_id}, progress={progress}, but value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success."
);
let chat_type = match step.get(..3) {
Some("vc-") => Chattype::Single,
Some("vg-") => Chattype::Group,
Some("vb-") => Chattype::OutBroadcast,
_ => bail!("Unknown securejoin step {step}"),
};
context.emit_event(EventType::SecurejoinInviterProgress {
contact_id,
chat_type,
progress,
});
Ok(())
}
/// Generates a Secure Join QR code.
@@ -346,7 +360,7 @@ pub(crate) async fn handle_securejoin_handshake(
return Ok(HandshakeMessage::Ignore);
}
inviter_progress(context, contact_id, 300);
inviter_progress(context, contact_id, step, 300)?;
let from_addr = ContactAddress::new(&mime_message.from.addr)?;
let autocrypt_fingerprint = mime_message.autocrypt_fingerprint.as_deref().unwrap_or("");
@@ -442,7 +456,7 @@ pub(crate) async fn handle_securejoin_handshake(
ChatId::create_for_contact(context, contact_id).await?;
}
context.emit_event(EventType::ContactsChanged(Some(contact_id)));
inviter_progress(context, contact_id, 600);
inviter_progress(context, contact_id, step, 600)?;
if let Some(group_chat_id) = group_chat_id {
// Join group.
secure_connection_established(
@@ -455,8 +469,8 @@ pub(crate) async fn handle_securejoin_handshake(
chat::add_contact_to_chat_ex(context, Nosync, group_chat_id, contact_id, true)
.await?;
inviter_progress(context, contact_id, 800);
inviter_progress(context, contact_id, 1000);
inviter_progress(context, contact_id, step, 800)?;
inviter_progress(context, contact_id, step, 1000)?;
if step == "vb-request-with-auth" {
// For broadcasts, we don't want to delete the message,
// because the other device should also internally add the member
@@ -480,7 +494,7 @@ pub(crate) async fn handle_securejoin_handshake(
.await
.context("failed sending vc-contact-confirm message")?;
inviter_progress(context, contact_id, 1000);
inviter_progress(context, contact_id, step, 1000)?;
Ok(HandshakeMessage::Ignore) // "Done" would delete the message and break multi-device (the key from Autocrypt-header is needed)
}
}
@@ -609,11 +623,11 @@ pub(crate) async fn observe_securejoin_on_other_device(
ChatId::set_protection_for_contact(context, contact_id, mime_message.timestamp_sent).await?;
if step == "vg-member-added" {
inviter_progress(context, contact_id, 800);
inviter_progress(context, contact_id, step, 800)?;
}
// TODO superflous vb-member-added (we're early-returning above):
if step == "vg-member-added" || step == "vb-member-added" || step == "vc-contact-confirm" {
inviter_progress(context, contact_id, 1000);
inviter_progress(context, contact_id, step, 1000)?;
}
if step == "vg-request-with-auth" || step == "vc-request-with-auth" {