mirror of
https://github.com/chatmail/core.git
synced 2026-04-23 00:16:34 +03:00
fix: add info message if user tries to create a QR code for deprecated channel (#7399)
Fix https://github.com/chatmail/core/issues/7397: - Don't allow creating a QR code for such old channels.
This commit is contained in:
@@ -250,6 +250,18 @@ pub(crate) const ASM_BODY: &str = "This is the Autocrypt Setup Message \
|
||||
/// Period between `sql::housekeeping()` runs.
|
||||
pub(crate) const HOUSEKEEPING_PERIOD: i64 = 24 * 60 * 60;
|
||||
|
||||
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.
|
||||
|
||||
As we do not guarantee feature-stability for such experiments, this means, that you will need to create the channel again.
|
||||
|
||||
Here is what to do:
|
||||
• Create a new channel
|
||||
• Tap on the channel name
|
||||
• Tap on "QR Invite Code"
|
||||
• Have all recipients scan the QR code, or send them the link
|
||||
|
||||
If you have any questions, please send an email to delta@merlinux.eu or ask at https://support.delta.chat/."#;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use num_traits::FromPrimitive;
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::aheader::{Aheader, EncryptPreference};
|
||||
use crate::blob::BlobObject;
|
||||
use crate::chat::{self, Chat, PARAM_BROADCAST_SECRET, load_broadcast_secret};
|
||||
use crate::config::Config;
|
||||
use crate::constants::ASM_SUBJECT;
|
||||
use crate::constants::{ASM_SUBJECT, BROADCAST_INCOMPATIBILITY_MSG};
|
||||
use crate::constants::{Chattype, DC_FROM_HANDSHAKE};
|
||||
use crate::contact::{Contact, ContactId, Origin};
|
||||
use crate::context::Context;
|
||||
@@ -1212,17 +1212,7 @@ impl MimeFactory {
|
||||
// because this is an old broadcast channel,
|
||||
// created before we had symmetric encryption,
|
||||
// we show an error message.
|
||||
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.
|
||||
|
||||
As we do not guarantee feature-stability for such experiments, this means, that you will need to create the channel again.
|
||||
|
||||
Here is what to do:
|
||||
• Create a new channel
|
||||
• Tap on the channel name
|
||||
• Tap on "QR Invite Code"
|
||||
• Have all recipients scan the QR code, or send them the link
|
||||
|
||||
If you have any questions, please send an email to delta@merlinux.eu or ask at https://support.delta.chat/."#;
|
||||
let text = BROADCAST_INCOMPATIBILITY_MSG;
|
||||
chat::add_info_msg(context, chat.id, text, time()).await?;
|
||||
bail!(text);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@ use anyhow::{Context as _, Error, Result, bail, ensure};
|
||||
use deltachat_contact_tools::ContactAddress;
|
||||
use percent_encoding::{AsciiSet, utf8_percent_encode};
|
||||
|
||||
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, get_chat_id_by_grpid};
|
||||
use crate::chat::{
|
||||
self, Chat, ChatId, ChatIdBlocked, add_info_msg, get_chat_id_by_grpid, load_broadcast_secret,
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::constants::{Blocked, Chattype, NON_ALPHANUMERIC_WITHOUT_DOT};
|
||||
use crate::constants::{
|
||||
BROADCAST_INCOMPATIBILITY_MSG, Blocked, Chattype, NON_ALPHANUMERIC_WITHOUT_DOT,
|
||||
};
|
||||
use crate::contact::mark_contact_id_as_verified;
|
||||
use crate::contact::{Contact, ContactId, Origin};
|
||||
use crate::context::Context;
|
||||
@@ -104,6 +108,16 @@ pub async fn get_securejoin_qr(context: &Context, chat: Option<ChatId>) -> Resul
|
||||
error!(context, "get_securejoin_qr: {}.", err);
|
||||
bail!(err);
|
||||
}
|
||||
if chat.typ == Chattype::OutBroadcast {
|
||||
// If the user created the broadcast before updating Delta Chat,
|
||||
// then the secret will be missing, and the user needs to recreate the broadcast:
|
||||
if load_broadcast_secret(context, chat.id).await?.is_none() {
|
||||
warn!(context, "Not creating securejoin QR for old broadcast");
|
||||
let text = BROADCAST_INCOMPATIBILITY_MSG;
|
||||
add_info_msg(context, chat.id, text, time()).await?;
|
||||
bail!(text.to_string());
|
||||
}
|
||||
}
|
||||
Some(chat)
|
||||
}
|
||||
None => None,
|
||||
|
||||
Reference in New Issue
Block a user