Skip to content

Commit

Permalink
fix: add Auto-Submitted header in a single place
Browse files Browse the repository at this point in the history
This ensures we don't add multiple Auto-Submitted headers
when bots send vg-request or vc-request messages.

The change fixes failing
receive_imf::tests::test_bot_accepts_another_group_after_qr_scan
test.
  • Loading branch information
link2xt committed Aug 27, 2024
1 parent 099f0e2 commit 273158a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/mimefactory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,16 @@ impl MimeFactory {
"Auto-Submitted".to_string(),
"auto-generated".to_string(),
));
} else if let Loaded::Message { msg, .. } = &self.loaded {
if msg.param.get_cmd() == SystemMessage::SecurejoinMessage {
let step = msg.param.get(Param::Arg).unwrap_or_default();
if step != "vg-request" && step != "vc-request" {
headers.push(Header::new(
"Auto-Submitted".to_string(),
"auto-replied".to_string(),
));
}
}
}

if let Loaded::Message { chat, .. } = &self.loaded {
Expand Down Expand Up @@ -1192,12 +1202,6 @@ impl MimeFactory {
if let Some(id) = msg.param.get(Param::Arg4) {
headers.push(Header::new("Secure-Join-Group".into(), id.into()));
};
if step != "vg-request" && step != "vc-request" {
headers.push(Header::new(
"Auto-Submitted".to_string(),
"auto-replied".to_string(),
));
}
}
}
SystemMessage::ChatProtectionEnabled => {
Expand Down

0 comments on commit 273158a

Please sign in to comment.