From 439dad5d6a5700cdbd9a8eabed37ace5e8e823d0 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 1 Nov 2015 16:33:43 +0100 Subject: [PATCH] API actions: Check if removal of comments and downtimes was succesful refs #9080 --- lib/icinga/apiactions.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index 6c6e8495d..9f9850aa7 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -289,7 +289,12 @@ Dictionary::Ptr ApiActions::RemoveCommentByID(const ConfigObject::Ptr& object, Comment::RemoveComment(comment_id); - return ApiActions::CreateResult(200, "Successfully removed comment '" + comment_id + "'."); + Comment::Ptr comment = Comment::GetByName(comment_id); + + if (!comment) + return ApiActions::CreateResult(200, "Successfully removed comment '" + comment_id + "'."); + + return ApiActions::CreateResult(403, "Could not remove comment '" + comment_id + "'."); } Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object, @@ -353,7 +358,12 @@ Dictionary::Ptr ApiActions::RemoveDowntimeByID(const ConfigObject::Ptr& object, Downtime::RemoveDowntime(downtime_id, true); - return ApiActions::CreateResult(200, "Successfully removed downtime '" + downtime_id + "'."); + Downtime::Ptr downtime = Downtime::GetByName(downtime_id); + + if (!downtime) + return ApiActions::CreateResult(200, "Successfully removed downtime '" + downtime_id + "'."); + + return ApiActions::CreateResult(403, "Could not remove downtime '" + downtime_id + "'."); } Dictionary::Ptr ApiActions::ShutdownProcess(const ConfigObject::Ptr& object,