| 339 | } |
| 340 | |
| 341 | Value ClusterEvents::StateBeforeSuppressionChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params) |
| 342 | { |
| 343 | Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint(); |
| 344 | |
| 345 | if (!endpoint) { |
| 346 | Log(LogNotice, "ClusterEvents") |
| 347 | << "Discarding 'state before suppression changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed)."; |
| 348 | return Empty; |
| 349 | } |
| 350 | |
| 351 | Host::Ptr host = Host::GetByName(params->Get("host")); |
| 352 | |
| 353 | if (!host) |
| 354 | return Empty; |
| 355 | |
| 356 | Checkable::Ptr checkable; |
| 357 | |
| 358 | if (params->Contains("service")) |
| 359 | checkable = host->GetServiceByShortName(params->Get("service")); |
| 360 | else |
| 361 | checkable = host; |
| 362 | |
| 363 | if (!checkable) |
| 364 | return Empty; |
| 365 | |
| 366 | if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) { |
| 367 | Log(LogNotice, "ClusterEvents") |
| 368 | << "Discarding 'state before suppression changed' message for checkable '" << checkable->GetName() |
| 369 | << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access."; |
| 370 | return Empty; |
| 371 | } |
| 372 | |
| 373 | checkable->SetStateBeforeSuppression(ServiceState(int(params->Get("state_before_suppression"))), false, origin); |
| 374 | |
| 375 | return Empty; |
| 376 | } |
| 377 | |
| 378 | void ClusterEvents::SuppressedNotificationsChangedHandler(const Checkable::Ptr& checkable, const MessageOrigin::Ptr& origin) |
| 379 | { |
nothing calls this directly
no test coverage detected