From 08bc671fb74aceeeaf20565a4fd57c3fa8453ae2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 14 May 2020 13:58:03 +0200 Subject: [PATCH] Transmit the user who cancels a downtime --- .../forms/Command/Object/DeleteDowntimeCommandForm.php | 1 + .../forms/Command/Object/DeleteDowntimesCommandForm.php | 1 + .../Monitoring/Command/Object/DeleteDowntimeCommand.php | 2 ++ .../Command/Renderer/IcingaApiCommandRenderer.php | 7 ++++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index be2109eec..5b3f49adc 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -94,6 +94,7 @@ class DeleteDowntimeCommandForm extends CommandForm { $cmd = new DeleteDowntimeCommand(); $cmd + ->setAuthor($this->Auth()->getUser()->getUsername()) ->setDowntimeId($this->getElement('downtime_id')->getValue()) ->setDowntimeName($this->getElement('downtime_name')->getValue()) ->setIsService($this->getElement('downtime_is_service')->getValue()); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php index e278409da..d4ee80348 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -73,6 +73,7 @@ class DeleteDowntimesCommandForm extends CommandForm $delDowntime ->setDowntimeId($downtime->id) ->setDowntimeName($downtime->name) + ->setAuthor($this->Auth()->getUser()->getUsername()) ->setIsService(isset($downtime->service_description)); $this->getTransport($this->request)->send($delDowntime); } diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php index 63f4bbce3..a31486442 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php @@ -10,6 +10,8 @@ use Icinga\Module\Monitoring\Command\IcingaCommand; */ class DeleteDowntimeCommand extends IcingaCommand { + use CommandAuthor; + /** * ID of the downtime that is to be deleted * diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaApiCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaApiCommandRenderer.php index c22424383..7c22ef549 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaApiCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaApiCommandRenderer.php @@ -247,9 +247,10 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteDowntime(DeleteDowntimeCommand $command) { $endpoint = 'actions/remove-downtime'; - $data = array( - 'downtime' => $command->getDowntimeName() - ); + $data = [ + 'author' => $command->getAuthor(), + 'downtime' => $command->getDowntimeName() + ]; return IcingaApiCommand::create($endpoint, $data); }