From: Mauro Carvalho Chehab <[email protected]>

When a patch is delegated, it can be important to report it via
pwclient, as handing delegated patches may be different. So, add
an optional field at the email's body if this is happening.

Signed-off-by: Stephen Finucane <[email protected]>
Suggested-by: Mauro Carvalho Chehab <[email protected]>
---
 patchwork/tests/test_mboxviews.py | 30 +++++++++++++++++++++++++++++-
 patchwork/views/__init__.py       |  2 ++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/patchwork/tests/test_mboxviews.py 
b/patchwork/tests/test_mboxviews.py
index 9c82531..a2bee0d 100644
--- a/patchwork/tests/test_mboxviews.py
+++ b/patchwork/tests/test_mboxviews.py
@@ -27,7 +27,7 @@ import email
 from django.test import TestCase
 
 from patchwork.models import Patch, Comment
-from patchwork.tests.utils import defaults
+from patchwork.tests.utils import defaults, create_user
 
 
 class MboxPatchResponseTest(TestCase):
@@ -134,6 +134,34 @@ class MboxPassThroughHeaderTest(TestCase):
         self.assertContains(response, self.date_header)
 
 
+class MboxGeneratedHeaderTest(TestCase):
+    fixtures = ['default_states']
+
+    def setUp(self):
+        defaults.project.save()
+        self.person = defaults.patch_author_person
+        self.person.save()
+
+        self.user = create_user()
+
+        self.patch = Patch(project=defaults.project,
+                           msgid='p1',
+                           name='testpatch',
+                           submitter=self.person,
+                           delegate=self.user,
+                           content='')
+        self.patch.save()
+
+    def testPatchworkIdHeader(self):
+        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
+        self.assertContains(response, 'X-Patchwork-Id: %d' % self.patch.id)
+
+    def testPatchworkDelegateHeader(self):
+        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
+        self.assertContains(response,
+                            'X-Patchwork-Delegate: %s' % self.user.email)
+
+
 class MboxBrokenFromHeaderTest(TestCase):
     fixtures = ['default_states']
 
diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py
index bf6cad1..0a12b41 100644
--- a/patchwork/views/__init__.py
+++ b/patchwork/views/__init__.py
@@ -207,6 +207,8 @@ def patch_to_mbox(patch):
         str(Header(patch.submitter.name, mail.patch_charset)),
         patch.submitter.email))
     mail['X-Patchwork-Id'] = str(patch.id)
+    if patch.delegate:
+        mail['X-Patchwork-Delegate'] = str(patch.delegate.email)
     mail['Message-Id'] = patch.msgid
     mail.set_unixfrom('From patchwork ' + patch.date.ctime())
 
-- 
2.0.0

_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to