From 6c617f4dd7ce97128119fb03712e58ac4a6c37d8 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 20 May 2026 16:36:20 +0200 Subject: [PATCH 1/6] --wip-- [skip ci] --- src/chat/chat_tests.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index 813d290124..b1ba1f3b5d 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -2924,8 +2924,17 @@ async fn test_broadcast_change_name() -> Result<()> { let broadcast_id = create_broadcast(alice, "Channel".to_string()).await?; let qr = get_securejoin_qr(alice, Some(broadcast_id)).await.unwrap(); - tcm.section("Alice invites Bob to her channel"); - tcm.exec_securejoin_qr(bob, alice, &qr).await; + tcm.section("Alice changes the chat name after creating the QR code, but before someone joins"); + set_chat_name(alice, broadcast_id, "Updated name after creating QR code").await?; + alice.pop_sent_msg().await; + + { + tcm.section("Alice invites Bob to her channel"); + let bob_chat_id = tcm.exec_securejoin_qr(bob, alice, &qr).await; + let bob_chat = Chat::load_from_db(bob, bob_chat_id).await?; + assert_eq!(bob_chat.name, "Updated name after creating QR code"); + } + tcm.section("Alice invites Fiona to her channel"); tcm.exec_securejoin_qr(fiona, alice, &qr).await; From 64a3c818cdecb4cbe88de26bd7e15f2df00230ea Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 20 May 2026 16:47:43 +0200 Subject: [PATCH 2/6] fix: Update the channel title after joining if the QR code included a wrong title --- src/chat.rs | 7 +++++-- src/chat/chat_tests.rs | 11 +++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 11197d2616..39ba70823e 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -3660,17 +3660,20 @@ pub(crate) async fn create_out_broadcast_ex( |row| row.get(0), )?; ensure!(cnt == 0, "{cnt} chats exist with grpid {grpid}"); + let mut params: Params = Params::new(); + params.update_timestamp(Param::GroupNameTimestamp, time())?; t.execute( "INSERT INTO chats - (type, name, name_normalized, grpid, created_timestamp) - VALUES(?, ?, ?, ?, ?)", + (type, name, name_normalized, grpid, created_timestamp, param) + VALUES(?, ?, ?, ?, ?, ?)", ( Chattype::OutBroadcast, &chat_name, normalize_text(&chat_name), &grpid, timestamp, + params.to_string(), ), )?; let chat_id = ChatId::new(t.last_insert_rowid().try_into()?); diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index b1ba1f3b5d..d2abc0e73a 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -2922,17 +2922,16 @@ async fn test_broadcast_change_name() -> Result<()> { let fiona = &tcm.fiona().await; let broadcast_id = create_broadcast(alice, "Channel".to_string()).await?; - let qr = get_securejoin_qr(alice, Some(broadcast_id)).await.unwrap(); - - tcm.section("Alice changes the chat name after creating the QR code, but before someone joins"); - set_chat_name(alice, broadcast_id, "Updated name after creating QR code").await?; - alice.pop_sent_msg().await; + let mut qr = get_securejoin_qr(alice, Some(broadcast_id)).await.unwrap(); + // Something goes wrong with the title, e.g. maybe it gets ellipsized + // Note that the title always comes at the end for human readability + qr += "+wrong+title"; { tcm.section("Alice invites Bob to her channel"); let bob_chat_id = tcm.exec_securejoin_qr(bob, alice, &qr).await; let bob_chat = Chat::load_from_db(bob, bob_chat_id).await?; - assert_eq!(bob_chat.name, "Updated name after creating QR code"); + assert_eq!(bob_chat.name, "Channel"); } tcm.section("Alice invites Fiona to her channel"); From 1d2d96257819dd25b1c1e267d509b186ab217cda Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 20 May 2026 16:58:36 +0200 Subject: [PATCH 3/6] Check that modifying the title worked --- src/chat/chat_tests.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index d2abc0e73a..4e8e605ac0 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -2925,10 +2925,16 @@ async fn test_broadcast_change_name() -> Result<()> { let mut qr = get_securejoin_qr(alice, Some(broadcast_id)).await.unwrap(); // Something goes wrong with the title, e.g. maybe it gets ellipsized // Note that the title always comes at the end for human readability - qr += "+wrong+title"; + qr += "+modified+title"; { tcm.section("Alice invites Bob to her channel"); + let Qr::AskJoinBroadcast { name, .. } = check_qr(bob, &qr).await? else { + panic!(); + }; + assert_eq!(name, "Channel modified title"); + + // The channel's name gets fixed after actually joining the channel: let bob_chat_id = tcm.exec_securejoin_qr(bob, alice, &qr).await; let bob_chat = Chat::load_from_db(bob, bob_chat_id).await?; assert_eq!(bob_chat.name, "Channel"); From eb65880da781ee620bfcfa92f098db16ed0838b3 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 20 May 2026 17:22:48 +0200 Subject: [PATCH 4/6] Fix imports --- src/chat/chat_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index 4e8e605ac0..381a6e9d08 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -9,6 +9,7 @@ use crate::headerdef::HeaderDef; use crate::imex::{ImexMode, has_backup, imex}; use crate::message::{Message, MessengerMessage, delete_msgs}; use crate::mimeparser::{self, MimeMessage}; +use crate::qr::{Qr, check_qr}; use crate::receive_imf::receive_imf; use crate::securejoin::{get_securejoin_qr, join_securejoin}; use crate::test_utils; From 5dee6381e68d4a3723cd5baef0a2dc4aab722271 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Sat, 30 May 2026 15:43:34 +0200 Subject: [PATCH 5/6] docs: Don't wrongly say that broadcasts are unpromoted --- deltachat-jsonrpc/src/api.rs | 3 --- deltachat-rpc-client/src/deltachat_rpc_client/account.py | 3 --- src/chat.rs | 3 --- 3 files changed, 9 deletions(-) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index e70c2771b8..da3cb9db8b 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -1106,9 +1106,6 @@ impl CommandApi { /// because the word "channel" already appears a lot in the code, /// which would make it hard to grep for it. /// - /// After creation, the chat contains no recipients and is in _unpromoted_ state; - /// see [`CommandApi::create_group_chat`] for more information on the unpromoted state. - /// /// Returns the created chat's id. async fn create_broadcast(&self, account_id: u32, chat_name: String) -> Result { let ctx = self.get_context(account_id).await?; diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/account.py b/deltachat-rpc-client/src/deltachat_rpc_client/account.py index db24c8ff2b..8308291cc9 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/account.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/account.py @@ -340,9 +340,6 @@ def create_broadcast(self, name: str) -> Chat: because the word "channel" already appears a lot in the code, which would make it hard to grep for it. - After creation, the chat contains no recipients and is in _unpromoted_ state; - see `create_group()` for more information on the unpromoted state. - Returns the created chat. """ return Chat(self, self._rpc.create_broadcast(self.id, name)) diff --git a/src/chat.rs b/src/chat.rs index 39ba70823e..c3342db11b 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -3626,9 +3626,6 @@ pub(crate) async fn create_group_ex( /// because the word "channel" already appears a lot in the code, /// which would make it hard to grep for it. /// -/// After creation, the chat contains no recipients and is in _unpromoted_ state; -/// see [`create_group`] for more information on the unpromoted state. -/// /// Returns the created chat's id. pub async fn create_broadcast(context: &Context, chat_name: String) -> Result { let grpid = create_id(); From 76b28bbbfbec0c78ba62eca74ca89b76cc492167 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Sat, 30 May 2026 15:52:33 +0200 Subject: [PATCH 6/6] Remove redundant chat type check --- src/chat.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index c3342db11b..e9635c562a 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1782,9 +1782,7 @@ impl Chat { ); bail!("Cannot set message, contact for {} not found.", self.id); } - } else if matches!(self.typ, Chattype::Group | Chattype::OutBroadcast) - && self.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 - { + } else if self.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 { msg.param.set_int(Param::AttachChatAvatarAndDescription, 1); self.param .remove(Param::Unpromoted)