From 1014bf17a45c3d1931212f95fda5bb31079bf4b4 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Tue, 20 Jan 2026 15:11:22 +0100 Subject: [PATCH] It compiles --- deltachat-jsonrpc/src/api/types/qr.rs | 12 ++++++++++++ src/aheader.rs | 2 +- src/mimefactory.rs | 10 ++++------ src/qr.rs | 14 ++++++++++++++ src/securejoin/bob.rs | 16 +++++++--------- src/securejoin/qrinvite.rs | 8 +++++++- 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/deltachat-jsonrpc/src/api/types/qr.rs b/deltachat-jsonrpc/src/api/types/qr.rs index de05e79c6..5b58a06d8 100644 --- a/deltachat-jsonrpc/src/api/types/qr.rs +++ b/deltachat-jsonrpc/src/api/types/qr.rs @@ -19,6 +19,8 @@ pub enum QrObject { invitenumber: String, /// Authentication code. authcode: String, + /// Whether the sender supports the new Securejoin v3 protocol + is_v3: bool, }, /// Ask the user whether to join the group. AskVerifyGroup { @@ -34,6 +36,8 @@ pub enum QrObject { invitenumber: String, /// Authentication code. authcode: String, + /// Whether the sender supports the new Securejoin v3 protocol + is_v3: bool, }, /// Ask the user whether to join the broadcast channel. AskJoinBroadcast { @@ -54,6 +58,8 @@ pub enum QrObject { invitenumber: String, /// Authentication code. authcode: String, + /// Whether the sender supports the new Securejoin v3 protocol + is_v3: bool, }, /// Contact fingerprint is verified. /// @@ -229,6 +235,7 @@ impl From for QrObject { fingerprint, invitenumber, authcode, + is_v3, } => { let contact_id = contact_id.to_u32(); let fingerprint = fingerprint.to_string(); @@ -237,6 +244,7 @@ impl From for QrObject { fingerprint, invitenumber, authcode, + is_v3, } } Qr::AskVerifyGroup { @@ -246,6 +254,7 @@ impl From for QrObject { fingerprint, invitenumber, authcode, + is_v3, } => { let contact_id = contact_id.to_u32(); let fingerprint = fingerprint.to_string(); @@ -256,6 +265,7 @@ impl From for QrObject { fingerprint, invitenumber, authcode, + is_v3, } } Qr::AskJoinBroadcast { @@ -265,6 +275,7 @@ impl From for QrObject { fingerprint, authcode, invitenumber, + is_v3, } => { let contact_id = contact_id.to_u32(); let fingerprint = fingerprint.to_string(); @@ -275,6 +286,7 @@ impl From for QrObject { fingerprint, authcode, invitenumber, + is_v3, } } Qr::FprOk { contact_id } => { diff --git a/src/aheader.rs b/src/aheader.rs index 7f84ca0f4..2ae8f3f06 100644 --- a/src/aheader.rs +++ b/src/aheader.rs @@ -47,7 +47,7 @@ pub struct Aheader { pub public_key: SignedPublicKey, pub prefer_encrypt: EncryptPreference, - // Whether `_verified` attribute is present. + /// Whether `_verified` attribute is present. // // `_verified` attribute is an extension to `Autocrypt-Gossip` // header that is used to tell that the sender diff --git a/src/mimefactory.rs b/src/mimefactory.rs index ff6e50b30..9b818b25e 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1915,8 +1915,7 @@ fn render_outer_message( let mut buffer = Vec::new(); let cursor = Cursor::new(&mut buffer); outer_message.clone().write_part(cursor).ok(); - let message = String::from_utf8_lossy(&buffer).to_string(); - message + String::from_utf8_lossy(&buffer).to_string() } /// Takes the encrypted part, wraps it in a MimePart, @@ -2279,15 +2278,14 @@ pub(crate) async fn render_symm_encrypted_securejoin_message( let from_addr = context.get_primary_self_addr().await?; let from = new_address_with_name("", from_addr.to_string()); - - let mut to: Vec> = Vec::new(); - to.push(hidden_recipients()); - headers.push(("From", from.into())); + + let to: Vec> = vec![hidden_recipients()]; headers.push(( "To", mail_builder::headers::address::Address::new_list(to.clone()).into(), )); + headers.push(( "Subject", mail_builder::headers::text::Text::new("Secure-Join".to_string()).into(), diff --git a/src/qr.rs b/src/qr.rs index a289d9aaf..1ad348475 100644 --- a/src/qr.rs +++ b/src/qr.rs @@ -61,6 +61,9 @@ pub enum Qr { /// Authentication code. authcode: String, + + /// Whether the sender supports the new Securejoin v3 protocol + is_v3: bool, }, /// Ask the user whether to join the group. @@ -82,6 +85,9 @@ pub enum Qr { /// Authentication code. authcode: String, + + /// Whether the sender supports the new Securejoin v3 protocol + is_v3: bool, }, /// Ask whether to join the broadcast channel. @@ -106,6 +112,9 @@ pub enum Qr { invitenumber: String, /// Authentication code. authcode: String, + + /// Whether the sender supports the new Securejoin v3 protocol + is_v3: bool, }, /// Contact fingerprint is verified. @@ -501,6 +510,8 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result { let grpname = decode_name(¶m, "g")?; let broadcast_name = decode_name(¶m, "b")?; + let is_v3 = param.get("v") == Some(&"3"); + if let (Some(addr), Some(invitenumber), Some(authcode)) = (&addr, invitenumber, authcode) { let addr = ContactAddress::new(addr)?; let (contact_id, _) = Contact::add_or_lookup_ex( @@ -546,6 +557,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result { fingerprint, invitenumber, authcode, + is_v3, }) } } else if let (Some(grpid), Some(name)) = (grpid, broadcast_name) { @@ -581,6 +593,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result { fingerprint, invitenumber, authcode, + is_v3, }) } } else if context.is_self_addr(&addr).await? { @@ -605,6 +618,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result { fingerprint, invitenumber, authcode, + is_v3, }) } } else if let Some(addr) = addr { diff --git a/src/securejoin/bob.rs b/src/securejoin/bob.rs index e754f8ddb..533c8c855 100644 --- a/src/securejoin/bob.rs +++ b/src/securejoin/bob.rs @@ -1,6 +1,6 @@ //! Bob's side of SecureJoin handling, the joiner-side. -use anyhow::{Context as _, Result, bail}; +use anyhow::{Context as _, Result}; use super::HandshakeMessage; use super::qrinvite::QrInvite; @@ -363,27 +363,25 @@ pub(crate) async fn send_handshake_message( msg.id = MsgId::new(u32::try_from(raw_id)?); */ - let row_ids = create_send_msg_jobs(context, msg) - .await - .context("Failed to create send jobs")?; - let rfc724_mid = create_outgoing_rfc724_mid(); let contact = Contact::get_by_id(context, invite.contact_id()).await?; let recipient = contact.get_addr(); - + let attach_self_pubkey = false; let rendered_message = mimefactory::render_symm_encrypted_securejoin_message( context, - recipient, - rfc724_mid, + step.securejoin_header(invite), + &rfc724_mid, + attach_self_pubkey, invite.authcode(), ) .await?; + // TODO code duplication context .sql .execute( "INSERT INTO smtp (rfc724_mid, recipients, mime, msg_id) - VALUES (?1, ?2, ?3, ?4)", + VALUES (?1, ?2, ?3, ?4)", ( &rfc724_mid, &recipient, diff --git a/src/securejoin/qrinvite.rs b/src/securejoin/qrinvite.rs index 26c4cb436..ecef2b272 100644 --- a/src/securejoin/qrinvite.rs +++ b/src/securejoin/qrinvite.rs @@ -83,7 +83,7 @@ impl QrInvite { } pub fn is_v3(&self) -> bool { - match self { + match *self { QrInvite::Contact { is_v3, .. } => is_v3, QrInvite::Group { is_v3, .. } => is_v3, QrInvite::Broadcast { is_v3, .. } => is_v3, @@ -101,11 +101,13 @@ impl TryFrom for QrInvite { fingerprint, invitenumber, authcode, + is_v3, } => Ok(QrInvite::Contact { contact_id, fingerprint, invitenumber, authcode, + is_v3, }), Qr::AskVerifyGroup { grpname, @@ -114,6 +116,7 @@ impl TryFrom for QrInvite { fingerprint, invitenumber, authcode, + is_v3, } => Ok(QrInvite::Group { contact_id, fingerprint, @@ -121,6 +124,7 @@ impl TryFrom for QrInvite { grpid, invitenumber, authcode, + is_v3, }), Qr::AskJoinBroadcast { name, @@ -129,6 +133,7 @@ impl TryFrom for QrInvite { fingerprint, authcode, invitenumber, + is_v3, } => Ok(QrInvite::Broadcast { name, grpid, @@ -136,6 +141,7 @@ impl TryFrom for QrInvite { fingerprint, authcode, invitenumber, + is_v3, }), _ => bail!("Unsupported QR type"), }