Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/User/DeleteJob.php
Show All 24 Lines | public function handle() | ||||
} | } | ||||
// sanity checks | // sanity checks | ||||
if ($user->isDeleted()) { | if ($user->isDeleted()) { | ||||
$this->fail(new \Exception("User {$this->userId} is already marked as deleted.")); | $this->fail(new \Exception("User {$this->userId} is already marked as deleted.")); | ||||
return; | return; | ||||
} | } | ||||
if (\config('app.with_ldap') && $user->isLdapReady()) { | |||||
\App\Backends\LDAP::deleteUser($user); | \App\Backends\LDAP::deleteUser($user); | ||||
$user->status |= \App\User::STATUS_DELETED; | |||||
if ($user->isLdapReady()) { | |||||
$user->status ^= \App\User::STATUS_LDAP_READY; | $user->status ^= \App\User::STATUS_LDAP_READY; | ||||
$user->save(); | |||||
} | } | ||||
if ($user->isImapReady()) { | if ($user->isImapReady()) { | ||||
if (!\App\Backends\IMAP::deleteUser($user)) { | |||||
throw new \Exception("Failed to delete mailbox for user {$this->userId}."); | |||||
} | |||||
$user->status ^= \App\User::STATUS_IMAP_READY; | $user->status ^= \App\User::STATUS_IMAP_READY; | ||||
} | } | ||||
if (\config('database.connections.roundcube')) { | |||||
\App\Backends\Roundcube::deleteUser($user->email); | |||||
} | |||||
$user->status |= \App\User::STATUS_DELETED; | |||||
$user->save(); | $user->save(); | ||||
} | } | ||||
} | } |