API Commands: Only send acknowledgement expire time if not null

Icinga 2 v2.7.0 is more strict with the `expiry` attribute if sent
(cannot be null, or in the past).

While acknowledgments with expire time worked well (and do so with this patch),
the command renderer did not check whether the value is actually not null
before setting it into the data form. The boolean value from the checkbox is
not available in the command renderer unfortunately.

@lippserd: Verified working with and without expire time inside the Vagrant boxes.

fixes #2911
This commit is contained in:
Michael Friedrich 2017-08-08 12:53:39 +02:00
parent 72dfa6d8c0
commit 2c312adf94
1 changed files with 3 additions and 1 deletions

View File

@ -179,10 +179,12 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
$data = array(
'author' => $command->getAuthor(),
'comment' => $command->getComment(),
'expiry' => $command->getExpireTime(),
'sticky' => $command->getSticky(),
'notify' => $command->getNotify()
);
if ($command->getExpireTime() !== null) {
$data['expiry'] = $command->getExpireTime();
}
$this->applyFilter($data, $command->getObject());
return IcingaApiCommand::create($endpoint, $data);
}