From 273158a337993e85ff5e38380f2509c9da5d5288 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 26 Aug 2024 23:29:34 +0000 Subject: [PATCH] fix: add Auto-Submitted header in a single place 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. --- src/mimefactory.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index a6150be90..1e9296887 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -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 { @@ -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 => {