This commit is contained in:
Hocuri
2025-08-07 16:26:04 +02:00
parent 40e3c34f59
commit 58d0fd39b5
5 changed files with 19 additions and 20 deletions

View File

@@ -3867,13 +3867,13 @@ pub(crate) async fn load_broadcast_shared_secret(
context: &Context, context: &Context,
chat_id: ChatId, chat_id: ChatId,
) -> Result<Option<String>> { ) -> Result<Option<String>> {
Ok(context context
.sql .sql
.query_get_value( .query_get_value(
"SELECT secret FROM broadcasts_shared_secrets WHERE chat_id=?", "SELECT secret FROM broadcasts_shared_secrets WHERE chat_id=?",
(chat_id,), (chat_id,),
) )
.await?) .await
} }
pub(crate) async fn save_broadcast_shared_secret( pub(crate) async fn save_broadcast_shared_secret(
@@ -5213,7 +5213,7 @@ impl Context {
} }
} }
async fn handle_sync_create_chat(&self, action: &SyncAction, grpid: &String) -> Result<bool> { async fn handle_sync_create_chat(&self, action: &SyncAction, grpid: &str) -> Result<bool> {
Ok(match action { Ok(match action {
SyncAction::CreateOutBroadcast { SyncAction::CreateOutBroadcast {
chat_name, chat_name,
@@ -5222,7 +5222,7 @@ impl Context {
create_broadcast_ex( create_broadcast_ex(
self, self,
Nosync, Nosync,
grpid.clone(), grpid.to_string(),
chat_name.clone(), chat_name.clone(),
shared_secret.to_string(), shared_secret.to_string(),
) )

View File

@@ -2649,17 +2649,17 @@ async fn test_broadcast_change_name() -> Result<()> {
let fiona = &tcm.fiona().await; let fiona = &tcm.fiona().await;
tcm.section("Alice sends a message to Bob"); tcm.section("Alice sends a message to Bob");
let chat_alice = alice.create_chat(&bob).await; let chat_alice = alice.create_chat(bob).await;
send_text_msg(&alice, chat_alice.id, "hi!".to_string()).await?; send_text_msg(alice, chat_alice.id, "hi!".to_string()).await?;
bob.recv_msg(&alice.pop_sent_msg().await).await; bob.recv_msg(&alice.pop_sent_msg().await).await;
tcm.section("Bob sends a message to Alice"); tcm.section("Bob sends a message to Alice");
let chat_bob = bob.create_chat(&alice).await; let chat_bob = bob.create_chat(alice).await;
send_text_msg(&bob, chat_bob.id, "ho!".to_string()).await?; send_text_msg(bob, chat_bob.id, "ho!".to_string()).await?;
let msg = alice.recv_msg(&bob.pop_sent_msg().await).await; let msg = alice.recv_msg(&bob.pop_sent_msg().await).await;
assert!(msg.get_showpadlock()); assert!(msg.get_showpadlock());
let broadcast_id = create_broadcast(&alice, "Channel".to_string()).await?; let broadcast_id = create_broadcast(alice, "Channel".to_string()).await?;
let qr = get_securejoin_qr(alice, Some(broadcast_id)).await.unwrap(); let qr = get_securejoin_qr(alice, Some(broadcast_id)).await.unwrap();
tcm.section("Alice invites Bob to her channel"); tcm.section("Alice invites Bob to her channel");
@@ -2669,7 +2669,7 @@ async fn test_broadcast_change_name() -> Result<()> {
{ {
tcm.section("Alice changes the chat name"); tcm.section("Alice changes the chat name");
set_chat_name(&alice, broadcast_id, "My great broadcast").await?; set_chat_name(alice, broadcast_id, "My great broadcast").await?;
let sent = alice.pop_sent_msg().await; let sent = alice.pop_sent_msg().await;
tcm.section("Bob receives the name-change system message"); tcm.section("Bob receives the name-change system message");
@@ -2687,15 +2687,15 @@ async fn test_broadcast_change_name() -> Result<()> {
{ {
tcm.section("Alice changes the chat name again, but the system message is lost somehow"); tcm.section("Alice changes the chat name again, but the system message is lost somehow");
set_chat_name(&alice, broadcast_id, "Broadcast channel").await?; set_chat_name(alice, broadcast_id, "Broadcast channel").await?;
let chat = Chat::load_from_db(&alice, broadcast_id).await?; let chat = Chat::load_from_db(alice, broadcast_id).await?;
assert_eq!(chat.typ, Chattype::OutBroadcast); assert_eq!(chat.typ, Chattype::OutBroadcast);
assert_eq!(chat.name, "Broadcast channel"); assert_eq!(chat.name, "Broadcast channel");
assert!(!chat.is_self_talk()); assert!(!chat.is_self_talk());
tcm.section("Alice sends a text message 'ola!'"); tcm.section("Alice sends a text message 'ola!'");
send_text_msg(&alice, broadcast_id, "ola!".to_string()).await?; send_text_msg(alice, broadcast_id, "ola!".to_string()).await?;
let msg = alice.get_last_msg().await; let msg = alice.get_last_msg().await;
assert_eq!(msg.chat_id, chat.id); assert_eq!(msg.chat_id, chat.id);
} }
@@ -2717,7 +2717,7 @@ async fn test_broadcast_change_name() -> Result<()> {
assert_eq!(msg.subject, "Re: Broadcast channel"); assert_eq!(msg.subject, "Re: Broadcast channel");
assert!(msg.get_showpadlock()); assert!(msg.get_showpadlock());
assert!(msg.get_override_sender_name().is_none()); assert!(msg.get_override_sender_name().is_none());
let chat = Chat::load_from_db(&bob, msg.chat_id).await?; let chat = Chat::load_from_db(bob, msg.chat_id).await?;
assert_eq!(chat.typ, Chattype::InBroadcast); assert_eq!(chat.typ, Chattype::InBroadcast);
assert_ne!(chat.id, chat_bob.id); assert_ne!(chat.id, chat_bob.id);
assert_eq!(chat.name, "Broadcast channel"); assert_eq!(chat.name, "Broadcast channel");
@@ -2760,7 +2760,7 @@ async fn test_broadcast_multidev() -> Result<()> {
set_chat_name(alice0, a0_broadcast_id, "Broadcast channel 42").await?; set_chat_name(alice0, a0_broadcast_id, "Broadcast channel 42").await?;
let sent_msg = alice0.send_text(a0_broadcast_id, "hi").await; let sent_msg = alice0.send_text(a0_broadcast_id, "hi").await;
let msg = alice1.recv_msg(&sent_msg).await; let msg = alice1.recv_msg(&sent_msg).await;
let a1_broadcast_id = get_chat_id_by_grpid(&alice1, &a0_broadcast_chat.grpid) let a1_broadcast_id = get_chat_id_by_grpid(alice1, &a0_broadcast_chat.grpid)
.await? .await?
.unwrap() .unwrap()
.0; .0;

View File

@@ -8,7 +8,7 @@ use chrono::SubsecRound;
use deltachat_contact_tools::EmailAddress; use deltachat_contact_tools::EmailAddress;
use pgp::armor::BlockType; use pgp::armor::BlockType;
use pgp::composed::{ use pgp::composed::{
ArmorOptions, Deserializable, InnerRingResult, KeyType as PgpKeyType, Message, MessageBuilder, ArmorOptions, Deserializable, KeyType as PgpKeyType, Message, MessageBuilder,
SecretKeyParamsBuilder, SignedPublicKey, SignedPublicSubKey, SignedSecretKey, SecretKeyParamsBuilder, SignedPublicKey, SignedPublicSubKey, SignedSecretKey,
StandaloneSignature, SubkeyParamsBuilder, TheRing, StandaloneSignature, SubkeyParamsBuilder, TheRing,
}; };
@@ -272,7 +272,7 @@ pub fn decrypt(
session_keys: vec![], session_keys: vec![],
allow_legacy: false, allow_legacy: false,
}; };
let (msg, ring_result) = msg.decrypt_the_ring(ring, true)?; let (msg, _ring_result) = msg.decrypt_the_ring(ring, true)?;
// remove one layer of compression // remove one layer of compression
let msg = msg.decompress()?; let msg = msg.decompress()?;

View File

@@ -6,7 +6,6 @@ use percent_encoding::{NON_ALPHANUMERIC, utf8_percent_encode};
use crate::chat::{ use crate::chat::{
self, Chat, ChatId, ChatIdBlocked, ProtectionStatus, get_chat_id_by_grpid, self, Chat, ChatId, ChatIdBlocked, ProtectionStatus, get_chat_id_by_grpid,
load_broadcast_shared_secret,
}; };
use crate::chatlist_events; use crate::chatlist_events;
use crate::config::Config; use crate::config::Config;

View File

@@ -857,8 +857,8 @@ async fn test_send_avatar_in_securejoin() -> Result<()> {
//exec_securejoin_broadcast(&tcm, alice, bob).await; //exec_securejoin_broadcast(&tcm, alice, bob).await;
} }
let alice_on_bob = bob.add_or_lookup_contact_no_key(&alice).await; let alice_on_bob = bob.add_or_lookup_contact_no_key(alice).await;
let avatar = alice_on_bob.get_profile_image(&bob).await?.unwrap(); let avatar = alice_on_bob.get_profile_image(bob).await?.unwrap();
assert_eq!( assert_eq!(
avatar.file_name().unwrap().to_str().unwrap(), avatar.file_name().unwrap().to_str().unwrap(),
AVATAR_64x64_DEDUPLICATED AVATAR_64x64_DEDUPLICATED