From 287edb79326d1b8b4d85fc91383023a1b547e179 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 14 May 2020 13:54:04 +0200 Subject: [PATCH] Transmit the user who deletes a comment --- .../forms/Command/Object/DeleteCommentCommandForm.php | 1 + .../forms/Command/Object/DeleteCommentsCommandForm.php | 1 + .../Monitoring/Command/Object/DeleteCommentCommand.php | 2 ++ .../Command/Renderer/IcingaApiCommandRenderer.php | 7 ++++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php index 366d7ebc8..cd15b19cf 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php @@ -94,6 +94,7 @@ class DeleteCommentCommandForm extends CommandForm { $cmd = new DeleteCommentCommand(); $cmd + ->setAuthor($this->Auth()->getUser()->getUsername()) ->setCommentId($this->getElement('comment_id')->getValue()) ->setCommentName($this->getElement('comment_name')->getValue()) ->setIsService($this->getElement('comment_is_service')->getValue()); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php index fb8b13099..70ea7b8db 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php @@ -73,6 +73,7 @@ class DeleteCommentsCommandForm extends CommandForm $cmd ->setCommentId($comment->id) ->setCommentName($comment->name) + ->setAuthor($this->Auth()->getUser()->getUsername()) ->setIsService(isset($comment->service_description)); $this->getTransport($this->request)->send($cmd); } diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php index 4d791064f..348175a39 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php @@ -10,6 +10,8 @@ use Icinga\Module\Monitoring\Command\IcingaCommand; */ class DeleteCommentCommand extends IcingaCommand { + use CommandAuthor; + /** * ID of the comment 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 81883618d..c22424383 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaApiCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaApiCommandRenderer.php @@ -237,9 +237,10 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteComment(DeleteCommentCommand $command) { $endpoint = 'actions/remove-comment'; - $data = array( - 'comment' => $command->getCommentName() - ); + $data = [ + 'author' => $command->getAuthor(), + 'comment' => $command->getCommentName() + ]; return IcingaApiCommand::create($endpoint, $data); }