From 1259fa7918075aab2d33eecb0a01bc36a275cb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Fri, 12 Mar 2021 17:24:03 +0300 Subject: [PATCH 1/2] send notification on update failure --- app/Console/Commands/Update.php | 31 ++- app/Events/Install/UpdateFailed.php | 35 ++++ .../Update/SendNotificationOnFailure.php | 51 +++++ app/Notifications/Install/UpdateFailed.php | 125 ++++++++++++ app/Providers/Event.php | 3 + composer.json | 1 + composer.lock | 190 ++++++++++++------ config/update.php | 23 +++ resources/lang/en-GB/notifications.php | 17 ++ 9 files changed, 408 insertions(+), 68 deletions(-) create mode 100644 app/Events/Install/UpdateFailed.php create mode 100644 app/Listeners/Update/SendNotificationOnFailure.php create mode 100644 app/Notifications/Install/UpdateFailed.php create mode 100644 config/update.php diff --git a/app/Console/Commands/Update.php b/app/Console/Commands/Update.php index 2bdeec8c1..89ca9853b 100644 --- a/app/Console/Commands/Update.php +++ b/app/Console/Commands/Update.php @@ -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; } diff --git a/app/Events/Install/UpdateFailed.php b/app/Events/Install/UpdateFailed.php new file mode 100644 index 000000000..4a8367d9c --- /dev/null +++ b/app/Events/Install/UpdateFailed.php @@ -0,0 +1,35 @@ +alias = $alias; + $this->old = $old; + $this->new = $new; + $this->step = $step; + $this->message = $message; + } +} diff --git a/app/Listeners/Update/SendNotificationOnFailure.php b/app/Listeners/Update/SendNotificationOnFailure.php new file mode 100644 index 000000000..d0f17ec25 --- /dev/null +++ b/app/Listeners/Update/SendNotificationOnFailure.php @@ -0,0 +1,51 @@ +getNotifiableClass(); + + try { + $notifiable->notify(new Notification($event)); + } catch (Exception | RequestException $e) { + report($e); + } + } + + protected function getNotifiableClass() + { + return new class() { + use Notifiable; + + public function routeNotificationForMail() + { + return config('update.notifications.mail.to'); + } + + public function routeNotificationForSlack() + { + return config('update.notifications.slack.to'); + } + + public function getKey() + { + return 1; + } + }; + } +} diff --git a/app/Notifications/Install/UpdateFailed.php b/app/Notifications/Install/UpdateFailed.php new file mode 100644 index 000000000..348eafa6f --- /dev/null +++ b/app/Notifications/Install/UpdateFailed.php @@ -0,0 +1,125 @@ +event = $event; + $this->notifications = config('update.notifications'); + } + + /** + * Get the notification's channels. + * + * @param mixed $notifiable + * @return array|string + */ + public function via($notifiable) + { + $channels = []; + + foreach ($this->notifications as $channel => $settings) { + if (empty($settings['enabled'])) { + continue; + } + + $channels[] = $channel; + } + + return $channels; + } + + /** + * Build the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + $subject = trans('notifications.update.mail.subject', [ + 'domain' => request()->getHttpHost(), + ]); + + $message = trans('notifications.mail.message', [ + 'alias' => $this->getAliasName(), + 'current_version' => $this->event->old, + 'new_version' => $this->event->new, + 'step' => $this->event->step, + 'error_message' => $this->event->message, + ]); + + return (new MailMessage) + ->from($this->notifications['mail']['from'], $this->notifications['mail']['name']) + ->subject($subject) + ->line($message); + } + + /** + * Get the Slack representation of the notification. + * + * @param mixed $notifiable + * @return SlackMessage + */ + public function toSlack($notifiable) + { + $message = trans('notifications.update.slack.message', [ + 'domain' => request()->getHttpHost(), + ]); + + return (new SlackMessage) + ->error() + ->from($this->notifications['slack']['from'], $this->notifications['slack']['emoji']) + ->to($this->notifications['slack']['to']) + ->content($message) + ->attachment(function ($attachment) { + $attachment->fields([ + 'Alias' => $this->getAliasName(), + 'Current Version' => $this->event->old, + 'New Version' => $this->event->new, + 'Step' => $this->event->step, + 'Error Message' => $this->event->message, + ]); + }); + } + + protected function getAliasName() + { + if ($this->event->alias == 'core') { + return ucfirst($this->event->alias); + } + + $module = module($this->event->alias); + + if (empty($module)) { + return ucfirst($this->event->alias); + } + + return $module->getName(); + } +} diff --git a/app/Providers/Event.php b/app/Providers/Event.php index 1f7fac0e9..79cdda3b7 100644 --- a/app/Providers/Event.php +++ b/app/Providers/Event.php @@ -68,6 +68,9 @@ class Event extends Provider 'App\Events\Document\DocumentViewed' => [ 'App\Listeners\Document\MarkDocumentViewed', ], + 'App\Events\Install\UpdateFailed' => [ + 'App\Listeners\Update\SendNotificationOnFailure', + ], 'App\Events\Menu\AdminCreated' => [ 'App\Listeners\Menu\AddAdminItems', ], diff --git a/composer.json b/composer.json index 6b1c6112a..dce135407 100644 --- a/composer.json +++ b/composer.json @@ -42,6 +42,7 @@ "kyslik/column-sortable": "^6.0", "laracasts/flash": "3.2.*", "laravel/framework": "^8.12", + "laravel/slack-notification-channel": "^2.3", "laravel/tinker": "^2.5", "laravel/ui": "^3.0", "laravelcollective/html": "6.2.*", diff --git a/composer.lock b/composer.lock index 1e98d47f4..76cd4d174 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ed7f9185c4b320bd65bb1b8e281eeecf", + "content-hash": "4449f26ee6ccbc2ae7e1033d1010aaeb", "packages": [ { "name": "akaunting/laravel-firewall", @@ -572,16 +572,16 @@ }, { "name": "asm89/stack-cors", - "version": "v2.0.2", + "version": "v2.0.3", "source": { "type": "git", "url": "https://github.com/asm89/stack-cors.git", - "reference": "8d8f88b3b3830916be94292c1fbce84433efb1aa" + "reference": "9cb795bf30988e8c96dd3c40623c48a877bc6714" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/asm89/stack-cors/zipball/8d8f88b3b3830916be94292c1fbce84433efb1aa", - "reference": "8d8f88b3b3830916be94292c1fbce84433efb1aa", + "url": "https://api.github.com/repos/asm89/stack-cors/zipball/9cb795bf30988e8c96dd3c40623c48a877bc6714", + "reference": "9cb795bf30988e8c96dd3c40623c48a877bc6714", "shasum": "" }, "require": { @@ -622,9 +622,9 @@ ], "support": { "issues": "https://github.com/asm89/stack-cors/issues", - "source": "https://github.com/asm89/stack-cors/tree/v2.0.2" + "source": "https://github.com/asm89/stack-cors/tree/v2.0.3" }, - "time": "2020-10-29T16:03:21+00:00" + "time": "2021-03-11T06:42:03+00:00" }, { "name": "balping/json-raw-encoder", @@ -2599,16 +2599,16 @@ }, { "name": "enlightn/enlightn", - "version": "v1.17.0", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/enlightn/enlightn.git", - "reference": "6aed2f10c23532dfe9c011ce0b008047a6da51a2" + "reference": "4e2eff5b60a47a522e8a16204024266031be7513" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/enlightn/enlightn/zipball/6aed2f10c23532dfe9c011ce0b008047a6da51a2", - "reference": "6aed2f10c23532dfe9c011ce0b008047a6da51a2", + "url": "https://api.github.com/repos/enlightn/enlightn/zipball/4e2eff5b60a47a522e8a16204024266031be7513", + "reference": "4e2eff5b60a47a522e8a16204024266031be7513", "shasum": "" }, "require": { @@ -2676,9 +2676,9 @@ "support": { "docs": "https://www.laravel-enlightn.com/docs/", "issues": "https://github.com/enlightn/enlightn/issues", - "source": "https://github.com/enlightn/enlightn/tree/v1.17.0" + "source": "https://github.com/enlightn/enlightn/tree/v1.18.0" }, - "time": "2021-03-09T13:36:51+00:00" + "time": "2021-03-10T20:18:14+00:00" }, { "name": "enlightn/security-checker", @@ -4988,6 +4988,67 @@ }, "time": "2021-03-09T15:37:45+00:00" }, + { + "name": "laravel/slack-notification-channel", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/slack-notification-channel.git", + "reference": "f428e76b8d0a0a2ff413ab225eeb829b9a8ffc20" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/slack-notification-channel/zipball/f428e76b8d0a0a2ff413ab225eeb829b9a8ffc20", + "reference": "f428e76b8d0a0a2ff413ab225eeb829b9a8ffc20", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0|^7.0", + "illuminate/notifications": "~5.8.0|^6.0|^7.0|^8.0", + "php": "^7.1.3|^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.0|^8.0|^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + }, + "laravel": { + "providers": [ + "Illuminate\\Notifications\\SlackChannelServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Notifications\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Slack Notification Channel for laravel.", + "keywords": [ + "laravel", + "notifications", + "slack" + ], + "support": { + "issues": "https://github.com/laravel/slack-notification-channel/issues", + "source": "https://github.com/laravel/slack-notification-channel/tree/v2.3.1" + }, + "time": "2021-01-26T20:04:54+00:00" + }, { "name": "laravel/tinker", "version": "v2.6.1", @@ -5765,23 +5826,23 @@ }, { "name": "maatwebsite/excel", - "version": "3.1.27", + "version": "3.1.28", "source": { "type": "git", "url": "https://github.com/Maatwebsite/Laravel-Excel.git", - "reference": "584d65427eae4de0ba072297c8fac9b0d63dbc37" + "reference": "71f27435091a78906276d00133f287ed67dd390e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/584d65427eae4de0ba072297c8fac9b0d63dbc37", - "reference": "584d65427eae4de0ba072297c8fac9b0d63dbc37", + "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/71f27435091a78906276d00133f287ed67dd390e", + "reference": "71f27435091a78906276d00133f287ed67dd390e", "shasum": "" }, "require": { "ext-json": "*", "illuminate/support": "5.8.*|^6.0|^7.0|^8.0", "php": "^7.0|^8.0", - "phpoffice/phpspreadsheet": "^1.16" + "phpoffice/phpspreadsheet": "1.16.*" }, "require-dev": { "orchestra/testbench": "^6.0", @@ -5827,7 +5888,7 @@ ], "support": { "issues": "https://github.com/Maatwebsite/Laravel-Excel/issues", - "source": "https://github.com/Maatwebsite/Laravel-Excel/tree/3.1.27" + "source": "https://github.com/Maatwebsite/Laravel-Excel/tree/3.1.28" }, "funding": [ { @@ -5839,7 +5900,7 @@ "type": "github" } ], - "time": "2021-02-22T16:58:19+00:00" + "time": "2021-03-10T16:36:04+00:00" }, { "name": "maennchen/zipstream-php", @@ -9317,16 +9378,16 @@ }, { "name": "symfony/console", - "version": "v5.2.4", + "version": "v5.2.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556" + "reference": "938ebbadae1b0a9c9d1ec313f87f9708609f1b79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", - "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", + "url": "https://api.github.com/repos/symfony/console/zipball/938ebbadae1b0a9c9d1ec313f87f9708609f1b79", + "reference": "938ebbadae1b0a9c9d1ec313f87f9708609f1b79", "shasum": "" }, "require": { @@ -9394,7 +9455,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.4" + "source": "https://github.com/symfony/console/tree/v5.2.5" }, "funding": [ { @@ -9410,7 +9471,7 @@ "type": "tidelift" } ], - "time": "2021-02-23T10:08:49+00:00" + "time": "2021-03-06T13:42:15+00:00" }, { "name": "symfony/css-selector", @@ -10123,16 +10184,16 @@ }, { "name": "symfony/http-kernel", - "version": "v5.2.4", + "version": "v5.2.5", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "c452dbe4f385f030c3957821bf921b13815d6140" + "reference": "b8c63ef63c2364e174c3b3e0ba0bf83455f97f73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/c452dbe4f385f030c3957821bf921b13815d6140", - "reference": "c452dbe4f385f030c3957821bf921b13815d6140", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/b8c63ef63c2364e174c3b3e0ba0bf83455f97f73", + "reference": "b8c63ef63c2364e174c3b3e0ba0bf83455f97f73", "shasum": "" }, "require": { @@ -10215,7 +10276,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v5.2.4" + "source": "https://github.com/symfony/http-kernel/tree/v5.2.5" }, "funding": [ { @@ -10231,20 +10292,20 @@ "type": "tidelift" } ], - "time": "2021-03-04T18:05:55+00:00" + "time": "2021-03-10T17:07:35+00:00" }, { "name": "symfony/mime", - "version": "v5.2.4", + "version": "v5.2.5", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "5155d2fe14ef1eb150e3bdbbc1ec1455df95e9cd" + "reference": "554ba128f1955038b45db5e1fa7e93bfc683b139" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/5155d2fe14ef1eb150e3bdbbc1ec1455df95e9cd", - "reference": "5155d2fe14ef1eb150e3bdbbc1ec1455df95e9cd", + "url": "https://api.github.com/repos/symfony/mime/zipball/554ba128f1955038b45db5e1fa7e93bfc683b139", + "reference": "554ba128f1955038b45db5e1fa7e93bfc683b139", "shasum": "" }, "require": { @@ -10255,12 +10316,13 @@ "symfony/polyfill-php80": "^1.15" }, "conflict": { + "egulias/email-validator": "~3.0.0", "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", "symfony/mailer": "<4.4" }, "require-dev": { - "egulias/email-validator": "^2.1.10", + "egulias/email-validator": "^2.1.10|^3.1", "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/property-access": "^4.4|^5.1", @@ -10297,7 +10359,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v5.2.4" + "source": "https://github.com/symfony/mime/tree/v5.2.5" }, "funding": [ { @@ -10313,7 +10375,7 @@ "type": "tidelift" } ], - "time": "2021-02-15T18:55:04+00:00" + "time": "2021-03-07T16:08:20+00:00" }, { "name": "symfony/polyfill-ctype", @@ -11360,16 +11422,16 @@ }, { "name": "symfony/translation", - "version": "v5.2.4", + "version": "v5.2.5", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "74b0353ab34ff4cca827a2cf909e325d96815e60" + "reference": "0947ab1e3aabd22a6bef393874b2555d2bb976da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/74b0353ab34ff4cca827a2cf909e325d96815e60", - "reference": "74b0353ab34ff4cca827a2cf909e325d96815e60", + "url": "https://api.github.com/repos/symfony/translation/zipball/0947ab1e3aabd22a6bef393874b2555d2bb976da", + "reference": "0947ab1e3aabd22a6bef393874b2555d2bb976da", "shasum": "" }, "require": { @@ -11433,7 +11495,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v5.2.4" + "source": "https://github.com/symfony/translation/tree/v5.2.5" }, "funding": [ { @@ -11449,7 +11511,7 @@ "type": "tidelift" } ], - "time": "2021-03-04T15:41:09+00:00" + "time": "2021-03-06T07:59:01+00:00" }, { "name": "symfony/translation-contracts", @@ -11531,16 +11593,16 @@ }, { "name": "symfony/var-dumper", - "version": "v5.2.4", + "version": "v5.2.5", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "6a81fec0628c468cf6d5c87a4d003725e040e223" + "reference": "002ab5a36702adf0c9a11e6d8836623253e9045e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/6a81fec0628c468cf6d5c87a4d003725e040e223", - "reference": "6a81fec0628c468cf6d5c87a4d003725e040e223", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/002ab5a36702adf0c9a11e6d8836623253e9045e", + "reference": "002ab5a36702adf0c9a11e6d8836623253e9045e", "shasum": "" }, "require": { @@ -11599,7 +11661,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.2.4" + "source": "https://github.com/symfony/var-dumper/tree/v5.2.5" }, "funding": [ { @@ -11615,20 +11677,20 @@ "type": "tidelift" } ], - "time": "2021-02-18T23:11:19+00:00" + "time": "2021-03-06T07:59:01+00:00" }, { "name": "symfony/yaml", - "version": "v5.2.4", + "version": "v5.2.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "7d6ae0cce3c33965af681a4355f1c4de326ed277" + "reference": "298a08ddda623485208506fcee08817807a251dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/7d6ae0cce3c33965af681a4355f1c4de326ed277", - "reference": "7d6ae0cce3c33965af681a4355f1c4de326ed277", + "url": "https://api.github.com/repos/symfony/yaml/zipball/298a08ddda623485208506fcee08817807a251dd", + "reference": "298a08ddda623485208506fcee08817807a251dd", "shasum": "" }, "require": { @@ -11674,7 +11736,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.2.4" + "source": "https://github.com/symfony/yaml/tree/v5.2.5" }, "funding": [ { @@ -11690,7 +11752,7 @@ "type": "tidelift" } ], - "time": "2021-02-22T15:48:39+00:00" + "time": "2021-03-06T07:59:01+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -14313,16 +14375,16 @@ }, { "name": "wnx/laravel-stats", - "version": "v2.5.0", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/stefanzweifel/laravel-stats.git", - "reference": "d6237ba1e44def2abd89a1a96faa10f15e47358a" + "reference": "689408202f77cad97664458dcd6c59f9142dbdd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stefanzweifel/laravel-stats/zipball/d6237ba1e44def2abd89a1a96faa10f15e47358a", - "reference": "d6237ba1e44def2abd89a1a96faa10f15e47358a", + "url": "https://api.github.com/repos/stefanzweifel/laravel-stats/zipball/689408202f77cad97664458dcd6c59f9142dbdd7", + "reference": "689408202f77cad97664458dcd6c59f9142dbdd7", "shasum": "" }, "require": { @@ -14335,12 +14397,14 @@ "symfony/process": "^4.3 || ^5.0" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^2.18", "laravel/browser-kit-testing": "~5.0 || ~6.0 || ~7.0", "laravel/dusk": "~5.0 || ~6.0", "mockery/mockery": "^1.1", "orchestra/testbench": "^4.0 || ^5.0 || ^6.0", "phpunit/phpunit": "8.* || 9.*", "psalm/plugin-laravel": "^1.4", + "rector/rector": "^0.9", "vimeo/psalm": "^4.0" }, "type": "library", @@ -14378,7 +14442,7 @@ ], "support": { "issues": "https://github.com/stefanzweifel/laravel-stats/issues", - "source": "https://github.com/stefanzweifel/laravel-stats/tree/v2.5.0" + "source": "https://github.com/stefanzweifel/laravel-stats/tree/v2.5.1" }, "funding": [ { @@ -14390,7 +14454,7 @@ "type": "github" } ], - "time": "2020-11-20T19:49:06+00:00" + "time": "2021-03-11T18:36:42+00:00" } ], "aliases": [], diff --git a/config/update.php b/config/update.php new file mode 100644 index 000000000..55604b10b --- /dev/null +++ b/config/update.php @@ -0,0 +1,23 @@ + [ + + 'mail' => [ + 'enabled' => env('UPDATE_NOTIFICATIONS_MAIL_ENABLED', false), + 'name' => env('UPDATE_NOTIFICATIONS_MAIL_NAME', env('MAIL_FROM_NAME')), + 'from' => env('UPDATE_NOTIFICATIONS_MAIL_FROM', env('MAIL_FROM_ADDRESS')), + 'to' => env('UPDATE_NOTIFICATIONS_MAIL_TO', 'admin@mydomain.com'), + ], + + 'slack' => [ + 'enabled' => env('UPDATE_NOTIFICATIONS_SLACK_ENABLED', false), + 'emoji' => env('UPDATE_NOTIFICATIONS_SLACK_EMOJI', ':warning:'), + 'from' => env('UPDATE_NOTIFICATIONS_SLACK_FROM', 'Akaunting Update'), + 'to' => env('UPDATE_NOTIFICATIONS_SLACK_TO', '#my-channel'), + ], + + ], + +]; diff --git a/resources/lang/en-GB/notifications.php b/resources/lang/en-GB/notifications.php index 88c2f9da0..7ae710144 100644 --- a/resources/lang/en-GB/notifications.php +++ b/resources/lang/en-GB/notifications.php @@ -7,4 +7,21 @@ return [ 'salutation' => 'Regards,
:company_name', 'subcopy' => 'If you’re having trouble clicking the ":text" button, copy and paste the URL below into your web browser: [:url](:url)', + 'update' => [ + + 'mail' => [ + + 'subject' => '⚠️ Update failed on :domain', + 'message' => 'The update of :alias from :current_version to :new_version failed in :step step with the following message: :error_message', + + ], + + 'slack' => [ + + 'message' => 'Update failed on :domain', + + ], + + ], + ]; From 542bc34defbd39a49c21d7a7200b1018d994ec30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Fri, 12 Mar 2021 17:27:34 +0300 Subject: [PATCH 2/2] use app name instead of core --- app/Notifications/Install/UpdateFailed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Notifications/Install/UpdateFailed.php b/app/Notifications/Install/UpdateFailed.php index 348eafa6f..4fb418f69 100644 --- a/app/Notifications/Install/UpdateFailed.php +++ b/app/Notifications/Install/UpdateFailed.php @@ -111,7 +111,7 @@ class UpdateFailed extends Notification protected function getAliasName() { if ($this->event->alias == 'core') { - return ucfirst($this->event->alias); + return config('app.name'); } $module = module($this->event->alias);