mirror of
https://github.com/chatmail/core.git
synced 2026-09-22 13:01:21 +03:00
feat: stop creating info messages for old broadcast lists
Creating QR code or sending a message will still fail with a shorter error, but no info message will be created anymore. Most users should have migrated the channels by recreating them by now. This change is needed for moving loading of the shared secret to earlier stages of message preparation, otherwise mimefactory will have to create these info messages when loading the message into memory.
This commit is contained in:
@@ -199,18 +199,6 @@ pub(crate) const EDITED_PREFIX: &str = "✏️";
|
|||||||
/// Period between `sql::housekeeping()` runs.
|
/// Period between `sql::housekeeping()` runs.
|
||||||
pub(crate) const HOUSEKEEPING_PERIOD: i64 = 24 * 60 * 60;
|
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/."#;
|
|
||||||
|
|
||||||
/// Number of recent messages that should be resent to a new broadcast member.
|
/// Number of recent messages that should be resent to a new broadcast member.
|
||||||
/// Additionally, up to this amount of pinned messages will be resent.
|
/// Additionally, up to this amount of pinned messages will be resent.
|
||||||
pub(crate) const N_MSGS_TO_NEW_BROADCAST_MEMBER: usize = 10;
|
pub(crate) const N_MSGS_TO_NEW_BROADCAST_MEMBER: usize = 10;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use crate::aheader::{Aheader, EncryptPreference};
|
|||||||
use crate::blob::BlobObject;
|
use crate::blob::BlobObject;
|
||||||
use crate::chat::{self, Chat, PARAM_BROADCAST_SECRET, load_broadcast_secret};
|
use crate::chat::{self, Chat, PARAM_BROADCAST_SECRET, load_broadcast_secret};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::{BROADCAST_INCOMPATIBILITY_MSG, Chattype, DC_FROM_HANDSHAKE};
|
use crate::constants::{Chattype, DC_FROM_HANDSHAKE};
|
||||||
use crate::contact::{Contact, ContactId, Origin};
|
use crate::contact::{Contact, ContactId, Origin};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::download::PostMsgMetadata;
|
use crate::download::PostMsgMetadata;
|
||||||
@@ -1417,17 +1417,12 @@ impl MimeFactory {
|
|||||||
|
|
||||||
let shared_secret: Option<String> = match &self.loaded {
|
let shared_secret: Option<String> = match &self.loaded {
|
||||||
Loaded::Message { chat, msg } if should_encrypt_with_broadcast_secret(msg, chat) => {
|
Loaded::Message { chat, msg } if should_encrypt_with_broadcast_secret(msg, chat) => {
|
||||||
let secret = load_broadcast_secret(context, chat.id).await?;
|
// Sending a message may fail for old broadcast channels
|
||||||
if secret.is_none() {
|
// created before shared secrets were introduced.
|
||||||
// If there is no shared secret yet
|
let secret = load_broadcast_secret(context, chat.id)
|
||||||
// because this is an old broadcast channel,
|
.await?
|
||||||
// created before we had symmetric encryption,
|
.context("Broadcast has no secret")?;
|
||||||
// we show an error message.
|
Some(secret)
|
||||||
let text = BROADCAST_INCOMPATIBILITY_MSG;
|
|
||||||
chat::add_info_msg(context, chat.id, text).await?;
|
|
||||||
bail!(text);
|
|
||||||
}
|
|
||||||
secret
|
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,13 +4,9 @@ use anyhow::{Context as _, Error, Result, bail, ensure};
|
|||||||
use deltachat_contact_tools::ContactAddress;
|
use deltachat_contact_tools::ContactAddress;
|
||||||
use percent_encoding::{AsciiSet, utf8_percent_encode};
|
use percent_encoding::{AsciiSet, utf8_percent_encode};
|
||||||
|
|
||||||
use crate::chat::{
|
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, get_chat_id_by_grpid, load_broadcast_secret};
|
||||||
self, Chat, ChatId, ChatIdBlocked, add_info_msg, get_chat_id_by_grpid, load_broadcast_secret,
|
|
||||||
};
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::{
|
use crate::constants::{Blocked, Chattype, NON_ALPHANUMERIC_WITHOUT_DOT};
|
||||||
BROADCAST_INCOMPATIBILITY_MSG, Blocked, Chattype, NON_ALPHANUMERIC_WITHOUT_DOT,
|
|
||||||
};
|
|
||||||
use crate::contact::mark_contact_id_as_verified;
|
use crate::contact::mark_contact_id_as_verified;
|
||||||
use crate::contact::{Contact, ContactId, Origin};
|
use crate::contact::{Contact, ContactId, Origin};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
@@ -111,14 +107,11 @@ pub async fn get_securejoin_qr(context: &Context, chat: Option<ChatId>) -> Resul
|
|||||||
// If the user created the broadcast before updating Delta Chat,
|
// If the user created the broadcast before updating Delta Chat,
|
||||||
// then the secret will be missing, and the user needs to recreate the broadcast:
|
// then the secret will be missing, and the user needs to recreate the broadcast:
|
||||||
if load_broadcast_secret(context, chat.id).await?.is_none() {
|
if load_broadcast_secret(context, chat.id).await?.is_none() {
|
||||||
error!(
|
let err = format!(
|
||||||
context,
|
"Can't create QR code for old broadcast list {id} without a shared secret"
|
||||||
"Not creating securejoin QR for old broadcast {}, see chat for more info.",
|
|
||||||
chat.id,
|
|
||||||
);
|
);
|
||||||
let text = BROADCAST_INCOMPATIBILITY_MSG;
|
error!(context, "get_securejoin_qr: {err}.");
|
||||||
add_info_msg(context, chat.id, text).await?;
|
bail!(err);
|
||||||
bail!(text.to_string());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(chat)
|
Some(chat)
|
||||||
|
|||||||
Reference in New Issue
Block a user