Skip to content

Commit 781d3ab

Browse files
committed
fix: make should_do_gossip() return true even if we send securejoin only to Alice
1 parent 78d0193 commit 781d3ab

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/mimefactory.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -359,20 +359,25 @@ impl<'a> MimeFactory<'a> {
359359
}
360360
}
361361

362-
async fn should_do_gossip(&self, context: &Context) -> Result<bool> {
362+
async fn should_do_gossip(&self, context: &Context, multiple_recipients: bool) -> Result<bool> {
363363
match &self.loaded {
364364
Loaded::Message { chat } => {
365-
// beside key- and member-changes, force a periodic re-gossip.
366-
let gossiped_timestamp = chat.id.get_gossiped_timestamp(context).await?;
367-
let gossip_period = context.get_config_i64(Config::GossipPeriod).await?;
368-
if time() >= gossiped_timestamp + gossip_period {
365+
let cmd = self.msg.param.get_cmd();
366+
if cmd == SystemMessage::MemberAddedToGroup
367+
|| cmd == SystemMessage::SecurejoinMessage
368+
{
369369
Ok(true)
370+
} else if multiple_recipients {
371+
// beside key- and member-changes, force a periodic re-gossip.
372+
let gossiped_timestamp = chat.id.get_gossiped_timestamp(context).await?;
373+
let gossip_period = context.get_config_i64(Config::GossipPeriod).await?;
374+
if time() >= gossiped_timestamp + gossip_period {
375+
Ok(true)
376+
} else {
377+
Ok(false)
378+
}
370379
} else {
371-
let cmd = self.msg.param.get_cmd();
372-
// Do gossip in all Securejoin messages not to complicate the code. There's no
373-
// need in gossips in "vg-auth-required" messages f.e., but let them be.
374-
Ok(cmd == SystemMessage::MemberAddedToGroup
375-
|| cmd == SystemMessage::SecurejoinMessage)
380+
Ok(false)
376381
}
377382
}
378383
Loaded::Mdn { .. } => Ok(false),
@@ -698,9 +703,9 @@ impl<'a> MimeFactory<'a> {
698703
.fold(message, |message, header| message.header(header));
699704

700705
// Add gossip headers in chats with multiple recipients
701-
if (peerstates.len() > 1 || context.get_config_bool(Config::BccSelf).await?)
702-
&& self.should_do_gossip(context).await?
703-
{
706+
let multiple_recipients =
707+
peerstates.len() > 1 || context.get_config_bool(Config::BccSelf).await?;
708+
if self.should_do_gossip(context, multiple_recipients).await? {
704709
for peerstate in peerstates.iter().filter_map(|(state, _)| state.as_ref()) {
705710
if let Some(header) = peerstate.render_gossip_header(verified) {
706711
message = message.header(Header::new("Autocrypt-Gossip".into(), header));

0 commit comments

Comments
 (0)