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 11197d2616..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) @@ -3626,9 +3624,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(); @@ -3660,17 +3655,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 813d290124..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; @@ -2922,10 +2923,24 @@ 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(); + 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 += "+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"); + } - tcm.section("Alice invites Bob to her channel"); - tcm.exec_securejoin_qr(bob, alice, &qr).await; tcm.section("Alice invites Fiona to her channel"); tcm.exec_securejoin_qr(fiona, alice, &qr).await;