From: Trevor Gamblin <tgamb...@baylibre.com>

Rework the script for sending results to use send_raw_email and specify
the 'In-Reply-To' field so that patchtest replies to the emails, rather
than sending them standalone to the submitter and mailing list.

Signed-off-by: Trevor Gamblin <tgamb...@baylibre.com>
Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org>
(cherry picked from commit 0c45c92e7f26aea4edf2cfa577b7ba51384e59d3)
Signed-off-by: Steve Sakoman <st...@sakoman.com>
---
 scripts/patchtest-send-results | 39 ++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/scripts/patchtest-send-results b/scripts/patchtest-send-results
index 01b071159b..1df81f943a 100755
--- a/scripts/patchtest-send-results
+++ b/scripts/patchtest-send-results
@@ -59,7 +59,16 @@ subject_line = f"Patchtest results for {mbox_subject}"
 
 # extract the submitter email address and use it as the reply address
 # for the results
-reply_address = re.findall("<(.*)>", mbox[0]['from'])
+reply_address = re.findall("<(.*)>", mbox[0]['from'])[0]
+
+# extract the message ID and use that as the in-reply-to address
+in_reply_to = re.findall("<(.*)>", mbox[0]['Message-ID'])[0]
+
+# the address the results email is sent from
+from_address = "patcht...@automation.yoctoproject.org"
+
+# mailing list to CC
+cc_address = "openembedded-core@lists.openembedded.org"
 
 if "FAIL" in testresult:
     reply_contents = None
@@ -70,24 +79,18 @@ if "FAIL" in testresult:
         reply_contents = greeting + testresult + suggestions
 
     ses_client = boto3.client('ses', region_name='us-west-2')
-    response = ses_client.send_email(
-        Source='patcht...@automation.yoctoproject.org',
-        Destination={
-            'CcAddresses': ['openembedded-core@lists.openembedded.org'],
+    raw_data = 'From: ' + from_address + '\nTo: ' + reply_address + \
+        '\nCC: ' + cc_address + '\nSubject:' + subject_line + \
+        '\nIn-Reply-To:' + in_reply_to + \
+        '\nMIME-Version: 1.0" + \
+        "\nContent-type: 
Multipart/Mixed;boundary="NextPart"\n\n--NextPart\nContent-Type: 
text/plain\n\n' + \
+        reply_contents + '\n\n--NextPart'
+    response = ses_client.send_raw_email(
+        Source="patcht...@automation.yoctoproject.org",
+        RawMessage={
+            "Data": raw_data,
         },
-        ReplyToAddresses=reply_address,
-        Message={
-            'Subject': {
-                'Data': subject_line,
-                'Charset': 'utf-8'
-            },
-            'Body': {
-                'Text': {
-                    'Data': reply_contents,
-                    'Charset': 'utf-8'
-                }
-            }
-        }
     )
+
 else:
     print(f"No failures identified for {args.patch}.")
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#190918): 
https://lists.openembedded.org/g/openembedded-core/message/190918
Mute This Topic: https://lists.openembedded.org/mt/102710691/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to