mirror of
https://github.com/simple-login/app.git
synced 2024-11-10 17:35:27 +08:00
Create directory alias with directory mailboxes
This commit is contained in:
parent
bc01479a72
commit
83e540d1d4
1 changed files with 9 additions and 1 deletions
|
@ -18,6 +18,7 @@ from app.models import (
|
|||
User,
|
||||
DeletedAlias,
|
||||
DomainDeletedAlias,
|
||||
AliasMailbox,
|
||||
)
|
||||
|
||||
|
||||
|
@ -65,12 +66,19 @@ def try_auto_create_directory(address: str) -> Optional[Alias]:
|
|||
try:
|
||||
LOG.d("create alias %s for directory %s", address, directory)
|
||||
|
||||
mailboxes = directory.mailboxes
|
||||
|
||||
alias = Alias.create(
|
||||
email=address,
|
||||
user_id=directory.user_id,
|
||||
directory_id=directory.id,
|
||||
mailbox_id=dir_user.default_mailbox_id,
|
||||
mailbox_id=mailboxes[0].id,
|
||||
)
|
||||
db.session.flush()
|
||||
for i in range(1, len(mailboxes)):
|
||||
AliasMailbox.create(
|
||||
alias_id=alias.id, mailbox_id=mailboxes[i].id,
|
||||
)
|
||||
|
||||
db.session.commit()
|
||||
return alias
|
||||
|
|
Loading…
Reference in a new issue