Skip to content

Commit 8f9cad8

Browse files
committed
feat: send vc- prefix instead of vg- in Secure-Join where accepted
This way we always send `Secure-Join: vc-request`, even when joining the group, and it is not visible to the server if we setup a new contact or join a group/channel.
1 parent c766397 commit 8f9cad8

2 files changed

Lines changed: 12 additions & 29 deletions

File tree

src/securejoin.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,10 @@ pub(crate) async fn handle_securejoin_handshake(
484484
)
485485
.await?;
486486

487-
let prefix = mime_message
488-
.get_header(HeaderDef::SecureJoin)
489-
.and_then(|step| step.get(..2))
490-
.unwrap_or("vc");
491-
492487
// Alice -> Bob
493-
send_alice_handshake_msg(
494-
context,
495-
autocrypt_contact_id,
496-
&format!("{prefix}-auth-required"),
497-
)
498-
.await
499-
.context("failed sending auth-required handshake message")?;
488+
send_alice_handshake_msg(context, autocrypt_contact_id, "vc-auth-required")
489+
.await
490+
.context("failed sending auth-required handshake message")?;
500491
Ok(HandshakeMessage::Done)
501492
}
502493
SecureJoinStep::AuthRequired => {

src/securejoin/bob.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::tools::{smeared_time, time};
2727
/// If Bob already has Alice's key, he sends `AUTH` token
2828
/// and forgets about the invite.
2929
/// If Bob does not yet have Alice's key, he sends `vc-request`
30-
/// or `vg-request` message and stores a row in the `bobstate` table
30+
/// message and stores a row in the `bobstate` table
3131
/// so he can check Alice's key against the fingerprint
3232
/// and send `AUTH` token later.
3333
///
@@ -301,14 +301,14 @@ pub(crate) async fn send_handshake_message(
301301
) -> Result<()> {
302302
let mut msg = Message {
303303
viewtype: Viewtype::Text,
304-
text: step.body_text(invite),
304+
text: step.body_text(),
305305
hidden: true,
306306
..Default::default()
307307
};
308308
msg.param.set_cmd(SystemMessage::SecurejoinMessage);
309309

310310
// Sends the step in Secure-Join header.
311-
msg.param.set(Param::Arg, step.securejoin_header(invite));
311+
msg.param.set(Param::Arg, step.securejoin_header());
312312

313313
match step {
314314
BobHandshakeMsg::Request => {
@@ -357,27 +357,19 @@ impl BobHandshakeMsg {
357357
/// This text has no significance to the protocol, but would be visible if users see
358358
/// this email message directly, e.g. when accessing their email without using
359359
/// DeltaChat.
360-
fn body_text(&self, invite: &QrInvite) -> String {
361-
format!("Secure-Join: {}", self.securejoin_header(invite))
360+
fn body_text(&self) -> String {
361+
format!("Secure-Join: {}", self.securejoin_header())
362362
}
363363

364364
/// Returns the `Secure-Join` header value.
365365
///
366366
/// This identifies the step this message is sending information about. Most protocol
367367
/// steps include additional information into other headers, see
368368
/// [`send_handshake_message`] for these.
369-
fn securejoin_header(&self, invite: &QrInvite) -> &'static str {
369+
fn securejoin_header(&self) -> &'static str {
370370
match self {
371-
Self::Request => match invite {
372-
QrInvite::Contact { .. } => "vc-request",
373-
QrInvite::Group { .. } => "vg-request",
374-
QrInvite::Broadcast { .. } => "vg-request",
375-
},
376-
Self::RequestWithAuth => match invite {
377-
QrInvite::Contact { .. } => "vc-request-with-auth",
378-
QrInvite::Group { .. } => "vg-request-with-auth",
379-
QrInvite::Broadcast { .. } => "vg-request-with-auth",
380-
},
371+
Self::Request => "vc-request",
372+
Self::RequestWithAuth => "vc-request-with-auth",
381373
}
382374
}
383375
}
@@ -447,7 +439,7 @@ async fn joining_chat_id(
447439
/// This has an `From<JoinerProgress> for usize` impl yielding numbers between 0 and a 1000
448440
/// which can be shown as a progress bar.
449441
pub(crate) enum JoinerProgress {
450-
/// vg-vc-request-with-auth sent.
442+
/// vc-request-with-auth sent.
451443
///
452444
/// Typically shows as "alice@addr verified, introducing myself."
453445
RequestWithAuthSent,

0 commit comments

Comments
 (0)