IcingaDB::PrepareObject(): round Notification#times.{begin,end} not to crash Go daemon

The latter expects ints, not floats - not to mention strings.
Luckily Icinga already enforces numeric strings so that we can cast it to number.
This commit is contained in:
Alexander A. Klimov 2023-06-27 12:53:08 +02:00
parent a3dabde28a
commit 415b810abf
1 changed files with 10 additions and 2 deletions

View File

@ -1383,8 +1383,16 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a
attributes->Set("timeperiod_id", GetObjectIdentifier(timeperiod));
if (notification->GetTimes()) {
attributes->Set("times_begin", notification->GetTimes()->Get("begin"));
attributes->Set("times_end",notification->GetTimes()->Get("end"));
auto begin (notification->GetTimes()->Get("begin"));
auto end (notification->GetTimes()->Get("end"));
if (begin != Empty) {
attributes->Set("times_begin", std::round((double)begin));
}
if (end != Empty) {
attributes->Set("times_end", std::round((double)end));
}
}
attributes->Set("notification_interval", notification->GetInterval());