Patchwork [v2,5/5] parsemail: Update a Person's name upon new email unless they are registered

mail settings
Submitter Doug Anderson
Date Nov. 18, 2013, 6 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/291947/
State Under Review
Delegated to: Stephen Finucane
Headers show


Doug Anderson - Nov. 18, 2013, 6 a.m.
Before this patch Patchwork didn't ever update a Person's real name.
The first time it saw an email address it looked at the name
associated with it and stashed that down as the official name.  This
was a good/bad thing.

The good was:
- It's hard to change a well-known's person real name (according to
  patchwork) by forging an email from them.

The bad was:
- If a person's name was wrong (or missing) in that first email, it
  was that way forever.
- If a person changed their name (maybe got married?) patchwork would
  never catch on to the new name.

The new rule will be that we'll update the name as long as the Person
isn't a registered patchwork user on this server.  The idea here is
that someone famous enough that people might want to forge an email
from them will probably have a patchwork account and can use that to
protect themselves.  Ideally this person will figure out how to get
their name changed in patchwork if they've had an actual name change.

It's not a perfect solution, but it seems like a reasonable

Signed-off-by: Doug Anderson <>
 apps/patchwork/bin/ | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)


diff --git a/apps/patchwork/bin/ b/apps/patchwork/bin/
index 92d6bb3..9d1acfe 100755
--- a/apps/patchwork/bin/
+++ b/apps/patchwork/bin/
@@ -69,15 +69,20 @@  def find_project(mail):
 def find_author(mail):
     name, email = parse_from(mail.get('From'))
-    new_person = False
+    save_required = False
         person = Person.objects.get(email__iexact = email)
     except Person.DoesNotExist:
         person = Person(name = name, email = email)
-        new_person = True
+        save_required = True
+    else:
+        # Update the name unless this is a registered user
+        if != name and not person.user:
+   = name
+            save_required = True
-    return (person, new_person)
+    return (person, save_required)
 def mail_date(mail):
     t = parsedate_tz(mail.get('Date', ''))