MCPcopy Create free account
hub / github.com/Icinga/icinga2 / LastNotifiedStatePerUserClearedAPIHandler

Method LastNotifiedStatePerUserClearedAPIHandler

lib/icinga/clusterevents.cpp:614–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614Value ClusterEvents::LastNotifiedStatePerUserClearedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
615{
616 auto endpoint (origin->FromClient->GetEndpoint());
617
618 if (!endpoint) {
619 Log(LogNotice, "ClusterEvents")
620 << "Discarding 'last notified state of user cleared' message from '"
621 << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
622
623 return Empty;
624 }
625
626 if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) {
627 Log(LogNotice, "ClusterEvents")
628 << "Discarding 'last notified state of user cleared' message from '"
629 << origin->FromClient->GetIdentity() << "': Unauthorized access.";
630
631 return Empty;
632 }
633
634 auto notification (Notification::GetByName(params->Get("notification")));
635
636 if (!notification) {
637 return Empty;
638 }
639
640 notification->GetLastNotifiedStatePerUser()->Clear();
641 Notification::OnLastNotifiedStatePerUserCleared(notification, origin);
642
643 return Empty;
644}
645
646void ClusterEvents::ForceNextCheckChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin)
647{

Callers

nothing calls this directly

Calls 5

LogClass · 0.85
GetEndpointMethod · 0.80
GetIdentityMethod · 0.80
GetMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected