~abompard/mailman/import21

« back to all changes in this revision

Viewing changes to src/mailman/utilities/importer.py

  • Committer: Aurélien Bompard
  • Date: 2013-10-11 15:49:09 UTC
  • Revision ID: aurelien@bompard.org-20131011154909-4xtd7asmsmc02zwb
Better handling of mixed case email addresses

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
    """
351
351
    usermanager = getUtility(IUserManager)
352
352
    for email in members:
353
 
        email = str_to_unicode(email)
 
353
        # for owners and members, the emails can have a mixed case, so
 
354
        # lowercase them all
 
355
        email = str_to_unicode(email).lower()
354
356
        roster = mlist.get_roster(role)
355
357
        if roster.get_member(email) is not None:
356
358
            print("%s is already imported with role %s" % (email, role),
357
359
                  file=sys.stderr)
358
360
            continue
 
361
        address = usermanager.get_address(email)
359
362
        user = usermanager.get_user(email)
360
363
        if user is None:
361
 
            merged_members = {}
362
 
            merged_members.update(config_dict.get("members", {}))
363
 
            merged_members.update(config_dict.get("digest_members", {}))
364
 
            if merged_members.get(email, 0) != 0:
365
 
                original_email = merged_members[email]
366
 
            else:
367
 
                original_email = email
368
 
            user = usermanager.create_user(str_to_unicode(original_email))
369
 
        address = usermanager.get_address(email)
370
 
        address.verified_on = datetime.datetime.now()
 
364
            user = usermanager.create_user()
 
365
            if address is None:
 
366
                merged_members = {}
 
367
                merged_members.update(config_dict.get("members", {}))
 
368
                merged_members.update(config_dict.get("digest_members", {}))
 
369
                if merged_members.get(email, 0) != 0:
 
370
                    original_email = str_to_unicode(merged_members[email])
 
371
                else:
 
372
                    original_email = email
 
373
                address = usermanager.create_address(original_email)
 
374
                address.verified_on = datetime.datetime.now()
 
375
            user.link(address)
371
376
        mlist.subscribe(address, role)
372
377
        member = roster.get_member(email)
373
378
        assert member is not None