Skip to content

Commit aad8f69

Browse files
authored
fix: Don't send ChatGroupId for broadcast channels (#6975)
Older versions of Delta Chat ignore the message if it contains a ChatGroupId header. ("older versions" means all versions without #6901, i.e.currently released versions) This means that without this PR, broadcast channel messages sent from current main don't arrive at a device running latest released DC. Part of #6884.
1 parent 35e107e commit aad8f69

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/chat/chat_tests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,11 @@ async fn test_broadcast() -> Result<()> {
26502650
assert!(msg.was_encrypted());
26512651
assert!(!msg.header_exists(HeaderDef::ChatGroupMemberTimestamps));
26522652
assert!(!msg.header_exists(HeaderDef::AutocryptGossip));
2653+
2654+
// If we sent a ChatGroupId header,
2655+
// older versions of DC would ignore the message
2656+
assert!(!msg.header_exists(HeaderDef::ChatGroupId));
2657+
26532658
let msg = bob.recv_msg(&sent_msg).await;
26542659
assert_eq!(msg.get_text(), "ola!");
26552660
assert_eq!(msg.subject, "Broadcast channel");

src/mimefactory.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::{BTreeSet, HashSet};
44
use std::io::Cursor;
55
use std::path::Path;
66

7-
use anyhow::{Context as _, Result, bail};
7+
use anyhow::{Context as _, Result, bail, ensure};
88
use base64::Engine as _;
99
use chrono::TimeZone;
1010
use deltachat_contact_tools::sanitize_bidi_characters;
@@ -1311,15 +1311,17 @@ impl MimeFactory {
13111311
));
13121312
}
13131313

1314-
if chat.typ == Chattype::Group || chat.typ == Chattype::OutBroadcast {
1314+
if chat.typ == Chattype::Group {
13151315
// Send group ID unless it is an ad hoc group that has no ID.
13161316
if !chat.grpid.is_empty() {
13171317
headers.push((
13181318
"Chat-Group-ID",
13191319
mail_builder::headers::raw::Raw::new(chat.grpid.clone()).into(),
13201320
));
13211321
}
1322+
}
13221323

1324+
if chat.typ == Chattype::Group || chat.typ == Chattype::OutBroadcast {
13231325
headers.push((
13241326
"Chat-Group-Name",
13251327
mail_builder::headers::text::Text::new(chat.name.to_string()).into(),
@@ -1333,6 +1335,7 @@ impl MimeFactory {
13331335

13341336
match command {
13351337
SystemMessage::MemberRemovedFromGroup => {
1338+
ensure!(chat.typ != Chattype::OutBroadcast);
13361339
let email_to_remove = msg.param.get(Param::Arg).unwrap_or_default();
13371340

13381341
if email_to_remove
@@ -1356,6 +1359,7 @@ impl MimeFactory {
13561359
}
13571360
}
13581361
SystemMessage::MemberAddedToGroup => {
1362+
ensure!(chat.typ != Chattype::OutBroadcast);
13591363
// TODO: lookup the contact by ID rather than email address.
13601364
// We are adding key-contacts, the cannot be looked up by address.
13611365
let email_to_add = msg.param.get(Param::Arg).unwrap_or_default();

0 commit comments

Comments
 (0)