Commit e736c5c0 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler Committed by Arkadiusz Hiler
Browse files

parsemail: Filter subject tag basing on list's address



Tag added by the mailing list usually matches local-part of it's email
address, so we should filter it out as well.

That helps us in the case when we have multiple project shearing a single
list.
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 87dc9ee0
......@@ -387,7 +387,8 @@ def find_content(project, mail):
ret = MailContent()
drop_prefixes = [project.linkname] + project.get_subject_prefix_tags()
drop_prefixes = [project.linkname, project.get_listemail_tag()]
drop_prefixes += project.get_subject_prefix_tags()
(name, prefixes) = clean_subject(mail.get('Subject'), drop_prefixes)
(x, n) = parse_series_marker(prefixes)
refs = build_references_list(mail)
......
......@@ -109,6 +109,9 @@ class Project(models.Model):
def get_subject_prefix_tags(self):
return get_comma_separated_field(self.subject_prefix_tags)
def get_listemail_tag(self):
return self.listemail.split("@")[0]
def __str__(self):
return self.name
......
......@@ -426,6 +426,11 @@ class MultipleProjectsPerMailingListTest(TestCase):
listemail='2@example.com')
self.project2.save()
self.project3 = Project(linkname='test-project-3', name='Project 3',
listid='list.example.com',
listemail='3@example.com')
self.project3.save()
def testTagList(self):
self.project1.subject_prefix_tags = ''
self.assertEquals(self.project1.get_subject_prefix_tags(), [])
......@@ -490,6 +495,16 @@ class MultipleProjectsPerMailingListTest(TestCase):
patch = Patch.objects.all()[0]
self.assertEquals(patch.name, 'Subject')
def testStripListemailTag(self):
self.project3.subject_prefix_tags = 'i-g-t'
self.project3.listemail = 'intel-gfx@example.com'
self.project3.save()
email = create_email(defaults.patch, project=self.project3,
subject='[intel-gfx] [PATCH i-g-t] Subject')
parse_mail(email)
patch = Patch.objects.all()[0]
self.assertEquals(patch.name, 'Subject')
class MBoxPatchTest(PatchTest):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment