Check for notify setting. Also close #741 (send notification via API)
This commit is contained in:
@@ -158,7 +158,12 @@ class IncidentController extends AbstractController
|
||||
trans('dashboard.incidents.add.success')
|
||||
);
|
||||
|
||||
if (array_get($incidentData, 'notify')) {
|
||||
$isEnabled = (bool) Setting::get('enable_subscribers', false);
|
||||
$mailAddress = env('MAIL_ADDRESS', false);
|
||||
$mailFrom = env('MAIL_NAME', false);
|
||||
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
|
||||
|
||||
if (array_get($incidentData, 'notify') && $subscribersEnabled) {
|
||||
event(new IncidentHasReportedEvent($incident));
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,12 @@ class ScheduleController extends AbstractController
|
||||
trans('dashboard.schedule.add.success')
|
||||
);
|
||||
|
||||
if (array_get($scheduleData, 'notify')) {
|
||||
$isEnabled = (bool) Setting::get('enable_subscribers', false);
|
||||
$mailAddress = env('MAIL_ADDRESS', false);
|
||||
$mailFrom = env('MAIL_NAME', false);
|
||||
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
|
||||
|
||||
if (array_get($scheduleData, 'notify') && $subscribersEnabled) {
|
||||
event(new MaintenanceHasScheduledEvent($incident));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -67,6 +69,15 @@ class IncidentController extends AbstractApiController
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
$isEnabled = (bool) Setting::get('enable_subscribers', false);
|
||||
$mailAddress = env('MAIL_ADDRESS', false);
|
||||
$mailFrom = env('MAIL_NAME', false);
|
||||
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
|
||||
|
||||
if (array_get($incidentData, 'notify') && $subscribersEnabled) {
|
||||
event(new IncidentHasReportedEvent($incident));
|
||||
}
|
||||
|
||||
if ($incident->isValid()) {
|
||||
return $this->item($incident);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user