send notification on update failure

This commit is contained in:
Denis Duliçi
2021-03-12 17:24:03 +03:00
parent a97709a8cb
commit 1259fa7918
9 changed files with 408 additions and 68 deletions

View File

@ -4,6 +4,7 @@ namespace App\Console\Commands;
use App\Events\Install\UpdateCopied;
use App\Events\Install\UpdateDownloaded;
use App\Events\Install\UpdateFailed;
use App\Events\Install\UpdateUnzipped;
use App\Jobs\Install\CopyFiles;
use App\Jobs\Install\DownloadFile;
@ -56,7 +57,11 @@ class Update extends Command
$this->company = $this->argument('company');
if (false === $this->new = $this->getNewVersion()) {
$this->error('Not able to get the latest version of ' . $this->alias . '!');
$message = 'Not able to get the latest version of ' . $this->alias . '!';
$this->error($message);
event(new UpdateFailed($this->alias, $this->new, $this->old, 'Version', $message));
return self::CMD_ERROR;
}
@ -112,7 +117,11 @@ class Update extends Command
event(new UpdateDownloaded($this->alias, $this->new, $this->old));
} catch (\Exception $e) {
$this->error($e->getMessage());
$message = $e->getMessage();
$this->error($message);
event(new UpdateFailed($this->alias, $this->new, $this->old, 'Download', $message));
return false;
}
@ -129,7 +138,11 @@ class Update extends Command
event(new UpdateUnzipped($this->alias, $this->new, $this->old));
} catch (\Exception $e) {
$this->error($e->getMessage());
$message = $e->getMessage();
$this->error($message);
event(new UpdateFailed($this->alias, $this->new, $this->old, 'Unzip', $message));
return false;
}
@ -146,7 +159,11 @@ class Update extends Command
event(new UpdateCopied($this->alias, $this->new, $this->old));
} catch (\Exception $e) {
$this->error($e->getMessage());
$message = $e->getMessage();
$this->error($message);
event(new UpdateFailed($this->alias, $this->new, $this->old, 'Copy Files', $message));
return false;
}
@ -161,7 +178,11 @@ class Update extends Command
try {
$this->dispatch(new FinishUpdate($this->alias, $this->new, $this->old, $this->company));
} catch (\Exception $e) {
$this->error($e->getMessage());
$message = $e->getMessage();
$this->error($message);
event(new UpdateFailed($this->alias, $this->new, $this->old, 'Finish', $message));
return false;
}