| 527 | } |
| 528 | |
| 529 | bool Notification::CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force, bool reminder) |
| 530 | { |
| 531 | String notificationName = GetName(); |
| 532 | String userName = user->GetName(); |
| 533 | |
| 534 | if (!force) { |
| 535 | TimePeriod::Ptr tp = user->GetPeriod(); |
| 536 | |
| 537 | if (tp && !tp->IsInside(Utility::GetTime())) { |
| 538 | Log(LogNotice, "Notification") |
| 539 | << "Not sending " << (reminder ? "reminder " : "") << "notifications for notification object '" |
| 540 | << notificationName << " and user '" << userName |
| 541 | << "': user period not in timeperiod '" << tp->GetName() << "'"; |
| 542 | return false; |
| 543 | } |
| 544 | |
| 545 | unsigned long ftype = type; |
| 546 | |
| 547 | Log(LogDebug, "Notification") |
| 548 | << "User '" << userName << "' notification '" << notificationName |
| 549 | << "', Type '" << NotificationTypeToString(type) |
| 550 | << "', TypeFilter: " << NotificationFilterToString(user->GetTypeFilter(), GetTypeFilterMap()) |
| 551 | << " (FType=" << ftype << ", TypeFilter=" << GetTypeFilter() << ")"; |
| 552 | |
| 553 | |
| 554 | if (!(ftype & user->GetTypeFilter())) { |
| 555 | Log(LogNotice, "Notification") |
| 556 | << "Not sending " << (reminder ? "reminder " : "") << "notifications for notification object '" |
| 557 | << notificationName << " and user '" << userName << "': type '" |
| 558 | << NotificationTypeToString(type) << "' does not match type filter: " |
| 559 | << NotificationFilterToString(user->GetTypeFilter(), GetTypeFilterMap()) << "."; |
| 560 | return false; |
| 561 | } |
| 562 | |
| 563 | /* check state filters it this is not a recovery notification */ |
| 564 | if (type != NotificationRecovery) { |
| 565 | Checkable::Ptr checkable = GetCheckable(); |
| 566 | Host::Ptr host; |
| 567 | Service::Ptr service; |
| 568 | tie(host, service) = GetHostService(checkable); |
| 569 | |
| 570 | unsigned long fstate; |
| 571 | String stateStr; |
| 572 | |
| 573 | if (service) { |
| 574 | fstate = ServiceStateToFilter(service->GetState()); |
| 575 | stateStr = NotificationServiceStateToString(service->GetState()); |
| 576 | } else { |
| 577 | fstate = HostStateToFilter(host->GetState()); |
| 578 | stateStr = NotificationHostStateToString(host->GetState()); |
| 579 | } |
| 580 | |
| 581 | Log(LogDebug, "Notification") |
| 582 | << "User '" << userName << "' notification '" << notificationName |
| 583 | << "', State '" << stateStr << "', StateFilter: " |
| 584 | << NotificationFilterToString(user->GetStateFilter(), GetStateFilterMap()) |
| 585 | << " (FState=" << fstate << ", StateFilter=" << user->GetStateFilter() << ")"; |
| 586 | |