From a83ad4b7f2add4701bcce22b759759aacceaffc3 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 15 Jan 2018 14:35:30 +0100 Subject: [PATCH] Explicitly pass 1 or 0 for notification filters in DB IDO --- lib/db_ido/hostdbobject.cpp | 12 ++++++------ lib/db_ido/servicedbobject.cpp | 20 ++++++++++---------- lib/db_ido/userdbobject.cpp | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 3c8c42058..808ecf640 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -81,11 +81,11 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const { "icon_image", host->GetIconImage() }, { "icon_image_alt", host->GetIconImageAlt() }, { "notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(host) }, - { "notify_on_down", (notificationStateFilter & ServiceWarning) || (notificationStateFilter && ServiceCritical) }, + { "notify_on_down", (notificationStateFilter & (ServiceWarning | ServiceCritical)) ? 1 : 0 }, { "notify_on_unreachable", 1 }, /* We don't have this filter and state, and as such we don't filter such notifications. */ - { "notify_on_recovery", notificationTypeFilter & NotificationRecovery }, - { "notify_on_flapping", (notificationTypeFilter & NotificationFlappingStart) || (notificationTypeFilter & NotificationFlappingEnd) }, - { "notify_on_downtime", (notificationTypeFilter & NotificationDowntimeStart) || (notificationTypeFilter & NotificationDowntimeEnd) || (notificationTypeFilter & NotificationDowntimeRemoved) } + { "notify_on_recovery", (notificationTypeFilter & NotificationRecovery) ? 1 : 0 }, + { "notify_on_flapping", (notificationTypeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) ? 1 : 0 }, + { "notify_on_downtime", (notificationTypeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) ? 1 : 0 } }); } @@ -275,8 +275,8 @@ void HostDbObject::OnConfigUpdateHeavy() { "dependent_host_object_id", host }, { "inherits_parent", 1 }, { "timeperiod_object_id", dep->GetPeriod() }, - { "fail_on_up", stateFilter & StateFilterUp }, - { "fail_on_down", stateFilter & StateFilterDown }, + { "fail_on_up", (stateFilter & StateFilterUp) ? 1 : 0 }, + { "fail_on_down", (stateFilter & StateFilterDown) ? 1 : 0 }, { "instance_id", 0 } /* DbConnection class fills in real ID */ }); queries.emplace_back(std::move(query2)); diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index 70ea4267e..2d80f526b 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -82,12 +82,12 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields() const { "icon_image", service->GetIconImage() }, { "icon_image_alt", service->GetIconImageAlt() }, { "notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(service) }, - { "notify_on_warning", notificationStateFilter & ServiceWarning }, - { "notify_on_unknown", notificationStateFilter & ServiceUnknown }, - { "notify_on_critical", notificationStateFilter & ServiceCritical }, - { "notify_on_recovery", notificationTypeFilter & NotificationRecovery }, - { "notify_on_flapping", (notificationTypeFilter & NotificationFlappingStart) || (notificationTypeFilter & NotificationFlappingEnd) }, - { "notify_on_downtime", (notificationTypeFilter & NotificationDowntimeStart) || (notificationTypeFilter & NotificationDowntimeEnd) || (notificationTypeFilter & NotificationDowntimeRemoved) } + { "notify_on_warning", (notificationStateFilter & ServiceWarning) ? 1 : 0 }, + { "notify_on_unknown", (notificationStateFilter & ServiceUnknown) ? 1 : 0 }, + { "notify_on_critical", (notificationStateFilter & ServiceCritical) ? 1 : 0 }, + { "notify_on_recovery", (notificationTypeFilter & NotificationRecovery) ? 1 : 0 }, + { "notify_on_flapping", (notificationTypeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) ? 1 : 0 }, + { "notify_on_downtime", (notificationTypeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) ? 1 : 0 } }); } @@ -238,10 +238,10 @@ void ServiceDbObject::OnConfigUpdateHeavy() { "dependent_service_object_id", service }, { "inherits_parent", 1 }, { "timeperiod_object_id", dep->GetPeriod() }, - { "fail_on_ok", stateFilter & StateFilterOK }, - { "fail_on_warning", stateFilter & StateFilterWarning }, - { "fail_on_critical", stateFilter & StateFilterCritical }, - { "fail_on_unknown", stateFilter & StateFilterUnknown }, + { "fail_on_ok", (stateFilter & StateFilterOK) ? 1 : 0 }, + { "fail_on_warning", (stateFilter & StateFilterWarning) ? 1 : 0 }, + { "fail_on_critical", (stateFilter & StateFilterCritical) ? 1 : 0 }, + { "fail_on_unknown", (stateFilter & StateFilterUnknown) ? 1 : 0 }, { "instance_id", 0 } /* DbConnection class fills in real ID */ }); queries.emplace_back(std::move(query1)); diff --git a/lib/db_ido/userdbobject.cpp b/lib/db_ido/userdbobject.cpp index f33883e3a..2078d57cc 100644 --- a/lib/db_ido/userdbobject.cpp +++ b/lib/db_ido/userdbobject.cpp @@ -51,16 +51,16 @@ Dictionary::Ptr UserDbObject::GetConfigFields() const { "host_notifications_enabled", user->GetEnableNotifications() }, { "service_notifications_enabled", user->GetEnableNotifications() }, { "can_submit_commands", 1 }, - { "notify_service_recovery", (typeFilter & NotificationRecovery) != 0 }, - { "notify_service_warning", (stateFilter & StateFilterWarning) != 0 }, - { "notify_service_unknown", (stateFilter & StateFilterUnknown) != 0 }, - { "notify_service_critical", (stateFilter & StateFilterCritical) != 0 }, - { "notify_service_flapping", (typeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) != 0 }, - { "notify_service_downtime", (typeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0 }, - { "notify_host_recovery", (typeFilter & NotificationRecovery) != 0 }, - { "notify_host_down", (stateFilter & StateFilterDown) != 0 }, - { "notify_host_flapping", (typeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) != 0 }, - { "notify_host_downtime", (typeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0 } + { "notify_service_recovery", (typeFilter & NotificationRecovery) ? 1 : 0 }, + { "notify_service_warning", (stateFilter & StateFilterWarning) ? 1 : 0 }, + { "notify_service_unknown", (stateFilter & StateFilterUnknown) ? 1 : 0 }, + { "notify_service_critical", (stateFilter & StateFilterCritical) ? 1 : 0 }, + { "notify_service_flapping", (typeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) ? 1 : 0 }, + { "notify_service_downtime", (typeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) ? 1 : 0 }, + { "notify_host_recovery", (typeFilter & NotificationRecovery) ? 1 : 0 }, + { "notify_host_down", (stateFilter & StateFilterDown) ? 1 : 0 }, + { "notify_host_flapping", (typeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) ? 1 : 0 }, + { "notify_host_downtime", (typeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) ? 1 : 0 } }); }