mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
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.
This commit is contained in:
@@ -2650,6 +2650,11 @@ async fn test_broadcast() -> Result<()> {
|
|||||||
assert!(msg.was_encrypted());
|
assert!(msg.was_encrypted());
|
||||||
assert!(!msg.header_exists(HeaderDef::ChatGroupMemberTimestamps));
|
assert!(!msg.header_exists(HeaderDef::ChatGroupMemberTimestamps));
|
||||||
assert!(!msg.header_exists(HeaderDef::AutocryptGossip));
|
assert!(!msg.header_exists(HeaderDef::AutocryptGossip));
|
||||||
|
|
||||||
|
// If we sent a ChatGroupId header,
|
||||||
|
// older versions of DC would ignore the message
|
||||||
|
assert!(!msg.header_exists(HeaderDef::ChatGroupId));
|
||||||
|
|
||||||
let msg = bob.recv_msg(&sent_msg).await;
|
let msg = bob.recv_msg(&sent_msg).await;
|
||||||
assert_eq!(msg.get_text(), "ola!");
|
assert_eq!(msg.get_text(), "ola!");
|
||||||
assert_eq!(msg.subject, "Broadcast channel");
|
assert_eq!(msg.subject, "Broadcast channel");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::collections::{BTreeSet, HashSet};
|
|||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use anyhow::{Context as _, Result, bail};
|
use anyhow::{Context as _, Result, bail, ensure};
|
||||||
use base64::Engine as _;
|
use base64::Engine as _;
|
||||||
use chrono::TimeZone;
|
use chrono::TimeZone;
|
||||||
use deltachat_contact_tools::sanitize_bidi_characters;
|
use deltachat_contact_tools::sanitize_bidi_characters;
|
||||||
@@ -1311,7 +1311,7 @@ impl MimeFactory {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if chat.typ == Chattype::Group || chat.typ == Chattype::OutBroadcast {
|
if chat.typ == Chattype::Group {
|
||||||
// Send group ID unless it is an ad hoc group that has no ID.
|
// Send group ID unless it is an ad hoc group that has no ID.
|
||||||
if !chat.grpid.is_empty() {
|
if !chat.grpid.is_empty() {
|
||||||
headers.push((
|
headers.push((
|
||||||
@@ -1319,7 +1319,9 @@ impl MimeFactory {
|
|||||||
mail_builder::headers::raw::Raw::new(chat.grpid.clone()).into(),
|
mail_builder::headers::raw::Raw::new(chat.grpid.clone()).into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if chat.typ == Chattype::Group || chat.typ == Chattype::OutBroadcast {
|
||||||
headers.push((
|
headers.push((
|
||||||
"Chat-Group-Name",
|
"Chat-Group-Name",
|
||||||
mail_builder::headers::text::Text::new(chat.name.to_string()).into(),
|
mail_builder::headers::text::Text::new(chat.name.to_string()).into(),
|
||||||
@@ -1333,6 +1335,7 @@ impl MimeFactory {
|
|||||||
|
|
||||||
match command {
|
match command {
|
||||||
SystemMessage::MemberRemovedFromGroup => {
|
SystemMessage::MemberRemovedFromGroup => {
|
||||||
|
ensure!(chat.typ != Chattype::OutBroadcast);
|
||||||
let email_to_remove = msg.param.get(Param::Arg).unwrap_or_default();
|
let email_to_remove = msg.param.get(Param::Arg).unwrap_or_default();
|
||||||
|
|
||||||
if email_to_remove
|
if email_to_remove
|
||||||
@@ -1356,6 +1359,7 @@ impl MimeFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SystemMessage::MemberAddedToGroup => {
|
SystemMessage::MemberAddedToGroup => {
|
||||||
|
ensure!(chat.typ != Chattype::OutBroadcast);
|
||||||
// TODO: lookup the contact by ID rather than email address.
|
// TODO: lookup the contact by ID rather than email address.
|
||||||
// We are adding key-contacts, the cannot be looked up by address.
|
// We are adding key-contacts, the cannot be looked up by address.
|
||||||
let email_to_add = msg.param.get(Param::Arg).unwrap_or_default();
|
let email_to_add = msg.param.get(Param::Arg).unwrap_or_default();
|
||||||
|
|||||||
Reference in New Issue
Block a user