Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/User/ResyncCommand.php
Show All 39 Lines | public function handle() | ||||
$this->error("User not found."); | $this->error("User not found."); | ||||
return 1; | return 1; | ||||
} | } | ||||
} else { | } else { | ||||
$users = User::withTrashed(); | $users = User::withTrashed(); | ||||
if ($deleted_only) { | if ($deleted_only) { | ||||
$users->whereNotNull('deleted_at') | $users->whereNotNull('deleted_at') | ||||
->where(function($query) { | ->where(function ($query) { | ||||
$query->where('status', '&', User::STATUS_IMAP_READY)->orWhere('status', '&', User::STATUS_LDAP_READY); | $query->where('status', '&', User::STATUS_IMAP_READY) | ||||
->orWhere('status', '&', User::STATUS_LDAP_READY); | |||||
}); | }); | ||||
} | } | ||||
$users = $users->orderBy('id')->cursor(); | $users = $users->orderBy('id')->cursor(); | ||||
} | } | ||||
// TODO: Maybe we should also have account:resync, domain:resync, resource:resync and so on. | // TODO: Maybe we should also have account:resync, domain:resync, resource:resync and so on. | ||||
Show All 25 Lines | public function handle() | ||||
} else { | } else { | ||||
if (!$user->isActive() || ($with_ldap && !$user->isLdapReady()) || !$user->isImapReady()) { | if (!$user->isActive() || ($with_ldap && !$user->isLdapReady()) || !$user->isImapReady()) { | ||||
if ($dry_run) { | if ($dry_run) { | ||||
$this->info("{$user->email}: will be pushed"); | $this->info("{$user->email}: will be pushed"); | ||||
continue; | continue; | ||||
} | } | ||||
\App\Jobs\User\CreateJob::dispatch($user->id); | \App\Jobs\User\CreateJob::dispatch($user->id); | ||||
} else if (!empty($req_user)) { | } elseif (!empty($req_user)) { | ||||
if ($dry_run) { | if ($dry_run) { | ||||
$this->info("{$user->email}: will be pushed"); | $this->info("{$user->email}: will be pushed"); | ||||
continue; | continue; | ||||
} | } | ||||
// We push the update only if a specific user is requested, | // We push the update only if a specific user is requested, | ||||
// We don't want to flood the database/backend with an update of all users | // We don't want to flood the database/backend with an update of all users | ||||
\App\Jobs\User\UpdateJob::dispatch($user->id); | \App\Jobs\User\UpdateJob::dispatch($user->id); | ||||
Show All 9 Lines |