}
}
-void Notification::BeginExecuteNotification(NotificationType type, const CheckResult::Ptr& cr, bool force, const String& author, const String& text)
+void Notification::BeginExecuteNotification(NotificationType type, const CheckResult::Ptr& cr, bool force, bool reminder, const String& author, const String& text)
{
Log(LogNotice, "Notification")
- << "Attempting to send notifications for notification object '" << GetName() << "'.";
+ << "Attempting to send " << (reminder ? "reminder " : " ") << "notifications for notification object '" << GetName() << "'.";
Checkable::Ptr checkable = GetCheckable();
if (tp && !tp->IsInside(Utility::GetTime())) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '" << GetName()
+ << "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '" << GetName()
<< "': not in timeperiod '" << tp->GetName() << "'";
return;
}
if (timesBegin != Empty && timesBegin >= 0 && now < checkable->GetLastHardStateChange() + timesBegin) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '" << GetName()
+ << "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '" << GetName()
<< "': before specified begin time (" << Utility::FormatDuration(timesBegin) << ")";
/* we need to adjust the next notification time
if (timesEnd != Empty && timesEnd >= 0 && now > checkable->GetLastHardStateChange() + timesEnd) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '" << GetName()
+ << "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '" << GetName()
<< "': after specified end time (" << Utility::FormatDuration(timesEnd) << ")";
return;
}
if (!(ftype & GetTypeFilter())) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '" << GetName() << "': type '"
+ << "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '" << GetName() << "': type '"
<< NotificationTypeToStringInternal(type) << "' does not match type filter: "
<< NotificationFilterToString(GetTypeFilter(), GetTypeFilterMap()) << ".";
return;
if (!(fstate & GetStateFilter())) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '" << GetName() << "': state '" << stateStr
+ << "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '" << GetName() << "': state '" << stateStr
<< "' does not match state filter: " << NotificationFilterToString(GetStateFilter(), GetStateFilterMap()) << ".";
return;
}
}
} else {
Log(LogNotice, "Notification")
- << "Not checking notification filters for notification object '" << GetName() << "': Notification was forced.";
+ << "Not checking " << (reminder ? "reminder " : " ") << "notification filters for notification object '" << GetName() << "': Notification was forced.";
}
{
continue;
}
- if (!CheckNotificationUserFilters(type, user, force)) {
+ if (!CheckNotificationUserFilters(type, user, force, reminder)) {
Log(LogNotice, "Notification")
<< "Notification filters for user '" << userName << "' not matched. Not sending notification.";
continue;
}
Log(LogInformation, "Notification")
- << "Sending '" << NotificationTypeToStringInternal(type) << "' notification '"
+ << "Sending " << (reminder ? "reminder " : " ") << "'" << NotificationTypeToStringInternal(type) << "' notification '"
<< GetName() << " for user '" << userName << "'";
Utility::QueueAsyncCallback(boost::bind(&Notification::ExecuteNotificationHelper, this, type, user, cr, force, author, text));
Service::OnNotificationSentToAllUsers(this, checkable, allNotifiedUsers, type, cr, author, text, MessageOrigin::Ptr());
}
-bool Notification::CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force)
+bool Notification::CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force, bool reminder)
{
if (!force) {
TimePeriod::Ptr tp = user->GetPeriod();
if (tp && !tp->IsInside(Utility::GetTime())) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '"
+ << "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '"
<< GetName() << " and user '" << user->GetName()
<< "': user period not in timeperiod '" << tp->GetName() << "'";
return false;
if (!(ftype & user->GetTypeFilter())) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '"
+ << "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '"
<< GetName() << " and user '" << user->GetName() << "': type '"
<< NotificationTypeToStringInternal(type) << "' does not match type filter: "
<< NotificationFilterToString(user->GetTypeFilter(), GetTypeFilterMap()) << ".";
if (!(fstate & user->GetStateFilter())) {
Log(LogNotice, "Notification")
- << "Not sending notifications for notification object '"
+ << "Not " << (reminder ? "reminder " : " ") << "sending notifications for notification object '"
<< GetName() << " and user '" << user->GetName() << "': state '" << stateStr
<< "' does not match state filter: " << NotificationFilterToString(user->GetStateFilter(), GetStateFilterMap()) << ".";
return false;
}
} else {
Log(LogNotice, "Notification")
- << "Not checking notification filters for notification object '"
+ << "Not checking " << (reminder ? "reminder " : " ") << "notification filters for notification object '"
<< GetName() << "' and user '" << user->GetName() << "': Notification was forced.";
}
void UpdateNotificationNumber(void);
void ResetNotificationNumber(void);
- void BeginExecuteNotification(NotificationType type, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = "");
-
- bool CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force);
+ void BeginExecuteNotification(NotificationType type, const CheckResult::Ptr& cr, bool force,
+ bool reminder = false, const String& author = "", const String& text = "");
Endpoint::Ptr GetCommandEndpoint(void) const;
private:
ObjectImpl<Checkable>::Ptr m_Checkable;
+ bool CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force, bool reminder);
+
void ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author = "", const String& text = "");
static bool EvaluateApplyRuleInstance(const intrusive_ptr<Checkable>& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule);