From 60334b701b10854eeb52fd39a5ffb7bdcba85eb9 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 20 May 2026 16:47:43 +0200 Subject: [PATCH] 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 11197d261..39ba70823 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 aa7985c8a..780b7627e 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");