It compiles

This commit is contained in:
Hocuri
2026-01-20 15:11:22 +01:00
parent 2566c5bcf4
commit 1014bf17a4
6 changed files with 45 additions and 17 deletions

View File

@@ -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<Qr> 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<Qr> for QrObject {
fingerprint,
invitenumber,
authcode,
is_v3,
}
}
Qr::AskVerifyGroup {
@@ -246,6 +254,7 @@ impl From<Qr> 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<Qr> for QrObject {
fingerprint,
invitenumber,
authcode,
is_v3,
}
}
Qr::AskJoinBroadcast {
@@ -265,6 +275,7 @@ impl From<Qr> 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<Qr> for QrObject {
fingerprint,
authcode,
invitenumber,
is_v3,
}
}
Qr::FprOk { contact_id } => {

View File

@@ -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

View File

@@ -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<Address<'static>> = Vec::new();
to.push(hidden_recipients());
headers.push(("From", from.into()));
let to: Vec<Address<'static>> = 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(),

View File

@@ -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<Qr> {
let grpname = decode_name(&param, "g")?;
let broadcast_name = decode_name(&param, "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<Qr> {
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<Qr> {
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<Qr> {
fingerprint,
invitenumber,
authcode,
is_v3,
})
}
} else if let Some(addr) = addr {

View File

@@ -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,

View File

@@ -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<Qr> 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<Qr> for QrInvite {
fingerprint,
invitenumber,
authcode,
is_v3,
} => Ok(QrInvite::Group {
contact_id,
fingerprint,
@@ -121,6 +124,7 @@ impl TryFrom<Qr> for QrInvite {
grpid,
invitenumber,
authcode,
is_v3,
}),
Qr::AskJoinBroadcast {
name,
@@ -129,6 +133,7 @@ impl TryFrom<Qr> for QrInvite {
fingerprint,
authcode,
invitenumber,
is_v3,
} => Ok(QrInvite::Broadcast {
name,
grpid,
@@ -136,6 +141,7 @@ impl TryFrom<Qr> for QrInvite {
fingerprint,
authcode,
invitenumber,
is_v3,
}),
_ => bail!("Unsupported QR type"),
}