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:
Hocuri
2025-11-05 17:16:54 +01:00
committed by GitHub
parent 81ba2d20d6
commit a40fd288fc
3 changed files with 30 additions and 14 deletions

View File

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