take care of domain aliases

This commit is contained in:
Gael Pasgrimaud
2016-11-24 16:05:34 +01:00
parent e7fd8c3341
commit fa417e108f
2 changed files with 11 additions and 1 deletions
@@ -62,7 +62,12 @@ class Repair(BaseCommand):
elif isinstance(obj, models.DomainAlias):
admin = obj.target.admins.first()
else:
admin = obj.domain.admins.first()
if obj.domain:
admin = obj.domain.admins.first()
else:
# Alias is an internal alias for domain alias
# we don't care if it's not owned
continue
if not admin:
# domain has no admin. use the first superuser found
admin = User.objects.filter(is_superuser=True,
+5
View File
@@ -39,3 +39,8 @@ class RepairTestCase(ModoTestCase):
management.call_command("modo", "repair", "--quiet", "--dry-run")
# assert its not fixed
self.assertIs(get_object_owner(mbox), None)
def test_management_command_with_nul_domain(self):
""" Just assume nothing raise when an alias has no domain"""
models.Alias.objects.create(address='@modoboa.xxx')
management.call_command("modo", "repair", "--quiet")