mirror of https://github.com/Icinga/icinga2.git
Implement status updates for contacts.
This commit is contained in:
parent
be582ad735
commit
17aedad7a7
|
@ -358,6 +358,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
|
|||
{
|
||||
ObjectLock olock(this);
|
||||
UpdateNotificationNumber();
|
||||
SetLastNotification(Utility::GetTime());
|
||||
}
|
||||
|
||||
RequestMessage rm;
|
||||
|
|
|
@ -37,6 +37,7 @@ User::User(const Dictionary::Ptr& serializedUpdate)
|
|||
RegisterAttribute("notification_period", Attribute_Config, &m_NotificationPeriod);
|
||||
RegisterAttribute("notification_type_filter", Attribute_Config, &m_NotificationTypeFilter);
|
||||
RegisterAttribute("notification_state_filter", Attribute_Config, &m_NotificationStateFilter);
|
||||
RegisterAttribute("last_notification", Attribute_Replicated, &m_LastNotification);
|
||||
}
|
||||
|
||||
User::~User(void)
|
||||
|
@ -112,6 +113,17 @@ unsigned long User::GetNotificationStateFilter(void) const
|
|||
return m_NotificationStateFilter;
|
||||
}
|
||||
|
||||
void User::SetLastNotification(double ts)
|
||||
{
|
||||
m_LastNotification = ts;
|
||||
Touch("last_notification");
|
||||
}
|
||||
|
||||
double User::GetLastNotification(void) const
|
||||
{
|
||||
return m_LastNotification;
|
||||
}
|
||||
|
||||
bool User::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
|
||||
{
|
||||
if (macro == "CONTACTNAME") {
|
||||
|
@ -131,3 +143,4 @@ bool User::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
TimePeriod::Ptr GetNotificationPeriod(void) const;
|
||||
unsigned long GetNotificationTypeFilter(void) const;
|
||||
unsigned long GetNotificationStateFilter(void) const;
|
||||
void SetLastNotification(double ts);
|
||||
double GetLastNotification(void) const;
|
||||
|
||||
Dictionary::Ptr GetMacros(void) const;
|
||||
|
||||
|
@ -69,6 +71,7 @@ private:
|
|||
Attribute<String> m_NotificationPeriod;
|
||||
Attribute<long> m_NotificationTypeFilter;
|
||||
Attribute<long> m_NotificationStateFilter;
|
||||
Attribute<double> m_LastNotification;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -72,13 +72,18 @@ Dictionary::Ptr UserDbObject::GetStatusFields(void) const
|
|||
Dictionary::Ptr fields = boost::make_shared<Dictionary>();
|
||||
User::Ptr user = static_pointer_cast<User>(GetObject());
|
||||
|
||||
fields->Set("host_notifications_enabled", Empty);
|
||||
fields->Set("service_notifications_enabled", Empty);
|
||||
fields->Set("last_host_notification", Empty);
|
||||
fields->Set("last_service_notification", Empty);
|
||||
fields->Set("host_notifications_enabled", user->GetEnableNotifications());
|
||||
fields->Set("service_notifications_enabled", user->GetEnableNotifications());
|
||||
fields->Set("last_host_notification", DbValue::FromTimestamp(user->GetLastNotification()));
|
||||
fields->Set("last_service_notification", DbValue::FromTimestamp(user->GetLastNotification()));
|
||||
fields->Set("modified_attributes", Empty);
|
||||
fields->Set("modified_host_attributes", Empty);
|
||||
fields->Set("modified_service_attributes", Empty);
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
bool UserDbObject::IsStatusAttribute(const String& attribute) const
|
||||
{
|
||||
return (attribute == "last_notification");
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
virtual Dictionary::Ptr GetConfigFields(void) const;
|
||||
virtual Dictionary::Ptr GetStatusFields(void) const;
|
||||
|
||||
virtual bool IsStatusAttribute(const String& attribute) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue