summaryrefslogtreecommitdiff
path: root/src/mailman/model/usermanager.py
diff options
context:
space:
mode:
authorBarry Warsaw2015-03-21 21:32:12 -0400
committerBarry Warsaw2015-03-21 21:32:12 -0400
commit783163c4e7eda6d5983bcca512db645c64dad349 (patch)
treeae0a79ac7d8b80ad4cc5a54f003ea61d3e01f3d0 /src/mailman/model/usermanager.py
parent18b7980823d2f9d5b7b0f50596cc05e8efb845e8 (diff)
downloadmailman-783163c4e7eda6d5983bcca512db645c64dad349.tar.gz
mailman-783163c4e7eda6d5983bcca512db645c64dad349.tar.zst
mailman-783163c4e7eda6d5983bcca512db645c64dad349.zip
Diffstat (limited to 'src/mailman/model/usermanager.py')
-rw-r--r--src/mailman/model/usermanager.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mailman/model/usermanager.py b/src/mailman/model/usermanager.py
index aefd955ed..ae499452b 100644
--- a/src/mailman/model/usermanager.py
+++ b/src/mailman/model/usermanager.py
@@ -46,6 +46,27 @@ class UserManager:
user.link(address)
return user
+ def make_user(self, email, display_name=None):
+ """See `IUserManager`."""
+ # See if there's already a user linked with the given address.
+ user = self.get_user(email)
+ if user is None:
+ # A user linked to this address does not yet exist. Is the
+ # address itself known but just not linked to a user?
+ address = self.get_address(email)
+ if address is None:
+ # Nope, we don't even know about this address, so create both
+ # the user and address now.
+ return self.create_user(email, display_name)
+ # The address exists, but it's not yet linked to a user. Create
+ # the empty user object and link them together.
+ user = self.create_user()
+ user.display_name = (
+ display_name if display_name else address.display_name)
+ user.link(address)
+ return user
+ return user
+
@dbconnection
def delete_user(self, store, user):
"""See `IUserManager`."""