Skip to content

Commit a40fd28

Browse files
authored
fix: add info message if user tries to create a QR code for deprecated channel (#7399)
Fix #7397: - Don't allow creating a QR code for such old channels.
1 parent 81ba2d2 commit a40fd28

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

src/constants.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,18 @@ pub(crate) const ASM_BODY: &str = "This is the Autocrypt Setup Message \
250250
/// Period between `sql::housekeeping()` runs.
251251
pub(crate) const HOUSEKEEPING_PERIOD: i64 = 24 * 60 * 60;
252252

253+
pub(crate) const BROADCAST_INCOMPATIBILITY_MSG: &str = r#"The up to now "experimental channels feature" is about to become an officially supported one. By that, privacy will be improved, it will become faster, and less traffic will be consumed.
254+
255+
As we do not guarantee feature-stability for such experiments, this means, that you will need to create the channel again.
256+
257+
Here is what to do:
258+
• Create a new channel
259+
• Tap on the channel name
260+
• Tap on "QR Invite Code"
261+
• Have all recipients scan the QR code, or send them the link
262+
263+
If you have any questions, please send an email to delta@merlinux.eu or ask at https://support.delta.chat/."#;
264+
253265
#[cfg(test)]
254266
mod tests {
255267
use num_traits::FromPrimitive;

src/mimefactory.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::aheader::{Aheader, EncryptPreference};
1717
use crate::blob::BlobObject;
1818
use crate::chat::{self, Chat, PARAM_BROADCAST_SECRET, load_broadcast_secret};
1919
use crate::config::Config;
20-
use crate::constants::ASM_SUBJECT;
20+
use crate::constants::{ASM_SUBJECT, BROADCAST_INCOMPATIBILITY_MSG};
2121
use crate::constants::{Chattype, DC_FROM_HANDSHAKE};
2222
use crate::contact::{Contact, ContactId, Origin};
2323
use crate::context::Context;
@@ -1212,17 +1212,7 @@ impl MimeFactory {
12121212
// because this is an old broadcast channel,
12131213
// created before we had symmetric encryption,
12141214
// we show an error message.
1215-
let text = r#"The up to now "experimental channels feature" is about to become an officially supported one. By that, privacy will be improved, it will become faster, and less traffic will be consumed.
1216-
1217-
As we do not guarantee feature-stability for such experiments, this means, that you will need to create the channel again.
1218-
1219-
Here is what to do:
1220-
• Create a new channel
1221-
• Tap on the channel name
1222-
• Tap on "QR Invite Code"
1223-
• Have all recipients scan the QR code, or send them the link
1224-
1225-
If you have any questions, please send an email to delta@merlinux.eu or ask at https://support.delta.chat/."#;
1215+
let text = BROADCAST_INCOMPATIBILITY_MSG;
12261216
chat::add_info_msg(context, chat.id, text, time()).await?;
12271217
bail!(text);
12281218
}

src/securejoin.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ use anyhow::{Context as _, Error, Result, bail, ensure};
44
use deltachat_contact_tools::ContactAddress;
55
use percent_encoding::{AsciiSet, utf8_percent_encode};
66

7-
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, get_chat_id_by_grpid};
7+
use crate::chat::{
8+
self, Chat, ChatId, ChatIdBlocked, add_info_msg, get_chat_id_by_grpid, load_broadcast_secret,
9+
};
810
use crate::config::Config;
9-
use crate::constants::{Blocked, Chattype, NON_ALPHANUMERIC_WITHOUT_DOT};
11+
use crate::constants::{
12+
BROADCAST_INCOMPATIBILITY_MSG, Blocked, Chattype, NON_ALPHANUMERIC_WITHOUT_DOT,
13+
};
1014
use crate::contact::mark_contact_id_as_verified;
1115
use crate::contact::{Contact, ContactId, Origin};
1216
use crate::context::Context;
@@ -104,6 +108,16 @@ pub async fn get_securejoin_qr(context: &Context, chat: Option<ChatId>) -> Resul
104108
error!(context, "get_securejoin_qr: {}.", err);
105109
bail!(err);
106110
}
111+
if chat.typ == Chattype::OutBroadcast {
112+
// If the user created the broadcast before updating Delta Chat,
113+
// then the secret will be missing, and the user needs to recreate the broadcast:
114+
if load_broadcast_secret(context, chat.id).await?.is_none() {
115+
warn!(context, "Not creating securejoin QR for old broadcast");
116+
let text = BROADCAST_INCOMPATIBILITY_MSG;
117+
add_info_msg(context, chat.id, text, time()).await?;
118+
bail!(text.to_string());
119+
}
120+
}
107121
Some(chat)
108122
}
109123
None => None,

0 commit comments

Comments
 (0)