diff mbox series

[b4] send: Add mail header to identify reflect messages

Message ID 20240910-reflect-header-v1-1-99d3b6eb0bcc@bootlin.com (mailing list archive)
State New
Headers show
Series [b4] send: Add mail header to identify reflect messages | expand

Commit Message

Louis Chauvet Sept. 10, 2024, 7:52 a.m. UTC
Series are often send with reflect before actual submission to check the
To/Cc and the content. Those reflected series are difficult to identify as
they are intended to be exaclty the same as the real mails.

To allows people to write filters for those reflect mails, add a
b4-specific header X-B4-Reflect.

---
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
 docs/contributor/send.rst | 1 +
 src/b4/__init__.py        | 2 ++
 2 files changed, 3 insertions(+)


---
base-commit: 88a27ce9018a1e886829be0a57336ae0594413e1
change-id: 20240910-reflect-header-6e63dd90c6a8

Best regards,

Comments

Konstantin Ryabitsev Sept. 10, 2024, 8:41 p.m. UTC | #1
On Tue, Sep 10, 2024 at 09:52:46AM GMT, Louis Chauvet wrote:
> Series are often send with reflect before actual submission to check the
> To/Cc and the content. Those reflected series are difficult to identify as
> they are intended to be exaclty the same as the real mails.
> 
> To allows people to write filters for those reflect mails, add a
> b4-specific header X-B4-Reflect.

I think we should actually put REFLECT into the subject, same as we do with
preview. I know the messages are supposed to look exactly as if they're
actually sent to the lists, but we can put "except REFLECT in the subject".

That would be a lot easier to identify than a header for a quick visual "did I
send this series yet?"

-K
Louis Chauvet Sept. 11, 2024, 8:39 a.m. UTC | #2
Le 10/09/24 - 16:41, Konstantin Ryabitsev a écrit :
> On Tue, Sep 10, 2024 at 09:52:46AM GMT, Louis Chauvet wrote:
> > Series are often send with reflect before actual submission to check the
> > To/Cc and the content. Those reflected series are difficult to identify as
> > they are intended to be exaclty the same as the real mails.
> > 
> > To allows people to write filters for those reflect mails, add a
> > b4-specific header X-B4-Reflect.
> 
> I think we should actually put REFLECT into the subject, same as we do with
> preview. I know the messages are supposed to look exactly as if they're
> actually sent to the lists, but we can put "except REFLECT in the subject".
> 
> That would be a lot easier to identify than a header for a quick visual "did I
> send this series yet?"
> 
> -K

For me the whole point of reflect is to have the exact same message, 
including the subject, so other tools involved (at least web endpoints 
for example) can treat it as a "normal" patch, that why I added a header 
and not a prefix.

I agree this is not very "visual". If you think adding a prefix is not an 
issue for existing tools, I can do a patch to add the REFLECT prefix.
diff mbox series

Patch

diff --git a/docs/contributor/send.rst b/docs/contributor/send.rst
index 54ed4746a4eeb59b729bd183db0ac36dad05a434..9ae760d519f2fe493195921fc4c6be234edc8046 100644
--- a/docs/contributor/send.rst
+++ b/docs/contributor/send.rst
@@ -229,6 +229,7 @@  When ``--reflect`` is on:
 * when using the web endpoint, the messages aren't added to the
   public-inbox feed
 * your branch is **not** automatically rerolled to the next revision
+* A specific header, ``X-B4-Reflect``, is set to ``1``.
 
 Checking things over with ``--preview-to`` **(v0.13+)**
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 811bbcaf028d78224242433eac9fdbeb03a306b3..f7ab2e8411267425e79afce54e3bdfac6943d8f1 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -3960,6 +3960,8 @@  def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[
     for msg in msgs:
         if not msg.get('X-Mailer'):
             msg.add_header('X-Mailer', f'b4 {__VERSION__}')
+        if not msg.get('X-B4-Reflect') and reflect:
+            msg.add_header('X-B4-Reflect', f'1')
         msg.set_charset('utf-8')
 
         if dryrun or web_endpoint: