API actions: Check if removal of comments and downtimes was succesful

refs #9080
This commit is contained in:
Michael Friedrich 2015-11-01 16:33:43 +01:00
parent 5c8386b388
commit 439dad5d6a
1 changed files with 12 additions and 2 deletions

View File

@ -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,