]> granicus.if.org Git - icinga2/commitdiff
Explicitly pass 1 or 0 for notification filters in DB IDO 5980/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Mon, 15 Jan 2018 13:35:30 +0000 (14:35 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Wed, 17 Jan 2018 12:38:48 +0000 (13:38 +0100)
lib/db_ido/hostdbobject.cpp
lib/db_ido/servicedbobject.cpp
lib/db_ido/userdbobject.cpp

index 3c8c42058241ea1a02f954f0daa154615d33f7ed..808ecf640f3c7b2c3ff93a422a51fad73c4b6a1a 100644 (file)
@@ -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));
index 70ea4267e1006d72e845d7e47643e94959e01042..2d80f526bbfe08e1ce33bcfa38a3da8ed650e2aa 100644 (file)
@@ -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));
index f33883e3acabe38665c783124e80537fc9e4f0df..2078d57cc59f396a109bc55ac5927b393f6d28b1 100644 (file)
@@ -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 }
        });
 }