Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/User/CreateJob.php
Show All 36 Lines | public function handle() | ||||
} | } | ||||
// sanity checks | // sanity checks | ||||
if ($user->isDeleted()) { | if ($user->isDeleted()) { | ||||
$this->fail(new \Exception("User {$this->userId} is marked as deleted.")); | $this->fail(new \Exception("User {$this->userId} is marked as deleted.")); | ||||
return; | return; | ||||
} | } | ||||
if ($user->deleted_at) { | if ($user->trashed()) { | ||||
$this->fail(new \Exception("User {$this->userId} is actually deleted.")); | $this->fail(new \Exception("User {$this->userId} is actually deleted.")); | ||||
return; | return; | ||||
} | } | ||||
if ($user->isLdapReady()) { | |||||
$this->fail(new \Exception("User {$this->userId} is already marked as ldap-ready.")); | |||||
return; | |||||
} | |||||
// see if the domain is ready | // see if the domain is ready | ||||
$domain = $user->domain(); | $domain = $user->domain(); | ||||
if (!$domain) { | if (!$domain) { | ||||
$this->fail(new \Exception("The domain for {$this->userId} does not exist.")); | $this->fail(new \Exception("The domain for {$this->userId} does not exist.")); | ||||
return; | return; | ||||
} | } | ||||
if ($domain->isDeleted()) { | if ($domain->isDeleted()) { | ||||
$this->fail(new \Exception("The domain for {$this->userId} is marked as deleted.")); | $this->fail(new \Exception("The domain for {$this->userId} is marked as deleted.")); | ||||
return; | return; | ||||
} | } | ||||
if (!$domain->isLdapReady()) { | if (!$domain->isLdapReady()) { | ||||
$this->release(60); | $this->release(60); | ||||
return; | return; | ||||
} | } | ||||
if (!$user->isLdapReady()) { | |||||
\App\Backends\LDAP::createUser($user); | \App\Backends\LDAP::createUser($user); | ||||
$user->status |= \App\User::STATUS_LDAP_READY; | $user->status |= \App\User::STATUS_LDAP_READY; | ||||
$user->save(); | $user->save(); | ||||
} | } | ||||
if (!$user->isImapReady()) { | |||||
if (!\App\Backends\IMAP::createUser($user)) { | |||||
machniak: It should be `app.with_imap` here. | |||||
throw new \Exception("Failed to create mailbox for user {$this->userId}."); | |||||
} | |||||
$user->status |= \App\User::STATUS_IMAP_READY; | |||||
} | |||||
$user->status |= \App\User::STATUS_ACTIVE; | |||||
$user->save(); | |||||
} | |||||
} | } |
It should be app.with_imap here.