Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/Resource/UpdateJob.php
Show All 13 Lines | class UpdateJob extends ResourceJob | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$resource = $this->getResource(); | $resource = $this->getResource(); | ||||
if (!$resource) { | if (!$resource) { | ||||
return; | return; | ||||
} | } | ||||
// Cancel the update if the resource is deleted or not yet in LDAP | // Cancel the update if the resource is deleted | ||||
if (!$resource->isLdapReady() || $resource->isDeleted()) { | if ($resource->isDeleted()) { | ||||
$this->delete(); | $this->delete(); | ||||
return; | return; | ||||
} | } | ||||
if (\config('app.with_ldap') && $resource->isLdapReady()) { | |||||
\App\Backends\LDAP::updateResource($resource); | \App\Backends\LDAP::updateResource($resource); | ||||
} | } | ||||
if ($resource->isImapReady()) { | |||||
if (!\App\Backends\IMAP::updateResource($resource, $this->properties)) { | |||||
throw new \Exception("Failed to update mailbox for resource {$this->resourceId}."); | |||||
} | |||||
} | |||||
} | |||||
} | } |