2019-02-25 14:48:22 +01:00
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2015-10-19 17:31:18 +02:00
# include "icinga/clusterevents.hpp"
# include "icinga/service.hpp"
# include "remote/apilistener.hpp"
# include "remote/endpoint.hpp"
# include "remote/messageorigin.hpp"
# include "remote/zone.hpp"
# include "remote/apifunction.hpp"
# include "remote/eventqueue.hpp"
# include "base/application.hpp"
# include "base/configtype.hpp"
# include "base/utility.hpp"
2017-05-15 15:51:39 +02:00
# include "base/perfdatavalue.hpp"
2015-10-19 17:31:18 +02:00
# include "base/exception.hpp"
# include "base/initialize.hpp"
# include "base/serializer.hpp"
# include "base/json.hpp"
# include <fstream>
using namespace icinga ;
INITIALIZE_ONCE ( & ClusterEvents : : StaticInitialize ) ;
REGISTER_APIFUNCTION ( CheckResult , event , & ClusterEvents : : CheckResultAPIHandler ) ;
REGISTER_APIFUNCTION ( SetNextCheck , event , & ClusterEvents : : NextCheckChangedAPIHandler ) ;
2020-03-05 15:34:12 +01:00
REGISTER_APIFUNCTION ( SetLastCheckStarted , event , & ClusterEvents : : LastCheckStartedChangedAPIHandler ) ;
2019-07-02 11:23:16 +02:00
REGISTER_APIFUNCTION ( SetSuppressedNotifications , event , & ClusterEvents : : SuppressedNotificationsChangedAPIHandler ) ;
2020-07-29 17:13:41 +02:00
REGISTER_APIFUNCTION ( SetSuppressedNotificationTypes , event , & ClusterEvents : : SuppressedNotificationTypesChangedAPIHandler ) ;
2015-10-19 17:31:18 +02:00
REGISTER_APIFUNCTION ( SetNextNotification , event , & ClusterEvents : : NextNotificationChangedAPIHandler ) ;
REGISTER_APIFUNCTION ( SetForceNextCheck , event , & ClusterEvents : : ForceNextCheckChangedAPIHandler ) ;
REGISTER_APIFUNCTION ( SetForceNextNotification , event , & ClusterEvents : : ForceNextNotificationChangedAPIHandler ) ;
REGISTER_APIFUNCTION ( SetAcknowledgement , event , & ClusterEvents : : AcknowledgementSetAPIHandler ) ;
REGISTER_APIFUNCTION ( ClearAcknowledgement , event , & ClusterEvents : : AcknowledgementClearedAPIHandler ) ;
REGISTER_APIFUNCTION ( ExecuteCommand , event , & ClusterEvents : : ExecuteCommandAPIHandler ) ;
2016-06-07 12:44:12 +02:00
REGISTER_APIFUNCTION ( SendNotifications , event , & ClusterEvents : : SendNotificationsAPIHandler ) ;
2016-06-15 11:27:01 +02:00
REGISTER_APIFUNCTION ( NotificationSentUser , event , & ClusterEvents : : NotificationSentUserAPIHandler ) ;
2016-08-16 09:30:10 +02:00
REGISTER_APIFUNCTION ( NotificationSentToAllUsers , event , & ClusterEvents : : NotificationSentToAllUsersAPIHandler ) ;
2015-10-19 17:31:18 +02:00
2018-01-04 04:25:35 +01:00
void ClusterEvents : : StaticInitialize ( )
2015-10-19 17:31:18 +02:00
{
Checkable : : OnNewCheckResult . connect ( & ClusterEvents : : CheckResultHandler ) ;
Checkable : : OnNextCheckChanged . connect ( & ClusterEvents : : NextCheckChangedHandler ) ;
2020-03-05 15:34:12 +01:00
Checkable : : OnLastCheckStartedChanged . connect ( & ClusterEvents : : LastCheckStartedChangedHandler ) ;
2019-07-02 11:23:16 +02:00
Checkable : : OnSuppressedNotificationsChanged . connect ( & ClusterEvents : : SuppressedNotificationsChangedHandler ) ;
2020-07-29 17:13:41 +02:00
Notification : : OnSuppressedNotificationsChanged . connect ( & ClusterEvents : : SuppressedNotificationTypesChangedHandler ) ;
2015-10-19 17:31:18 +02:00
Notification : : OnNextNotificationChanged . connect ( & ClusterEvents : : NextNotificationChangedHandler ) ;
Checkable : : OnForceNextCheckChanged . connect ( & ClusterEvents : : ForceNextCheckChangedHandler ) ;
Checkable : : OnForceNextNotificationChanged . connect ( & ClusterEvents : : ForceNextNotificationChangedHandler ) ;
2016-06-07 12:44:12 +02:00
Checkable : : OnNotificationsRequested . connect ( & ClusterEvents : : SendNotificationsHandler ) ;
2016-06-15 11:27:01 +02:00
Checkable : : OnNotificationSentToUser . connect ( & ClusterEvents : : NotificationSentUserHandler ) ;
2016-08-15 17:26:01 +02:00
Checkable : : OnNotificationSentToAllUsers . connect ( & ClusterEvents : : NotificationSentToAllUsersHandler ) ;
2015-10-19 17:31:18 +02:00
Checkable : : OnAcknowledgementSet . connect ( & ClusterEvents : : AcknowledgementSetHandler ) ;
Checkable : : OnAcknowledgementCleared . connect ( & ClusterEvents : : AcknowledgementClearedHandler ) ;
}
Dictionary : : Ptr ClusterEvents : : MakeCheckResultMessage ( const Checkable : : Ptr & checkable , const CheckResult : : Ptr & cr )
{
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::CheckResult " ) ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
else {
Value agent_service_name = checkable - > GetExtension ( " agent_service_name " ) ;
if ( ! agent_service_name . IsEmpty ( ) )
params - > Set ( " service " , agent_service_name ) ;
}
params - > Set ( " cr " , Serialize ( cr ) ) ;
message - > Set ( " params " , params ) ;
return message ;
}
void ClusterEvents : : CheckResultHandler ( const Checkable : : Ptr & checkable , const CheckResult : : Ptr & cr , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Dictionary : : Ptr message = MakeCheckResultMessage ( checkable , cr ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : CheckResultAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'check result' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2016-09-13 22:14:11 +02:00
CheckResult : : Ptr cr ;
Array : : Ptr vperf ;
if ( params - > Contains ( " cr " ) ) {
cr = new CheckResult ( ) ;
Dictionary : : Ptr vcr = params - > Get ( " cr " ) ;
2016-11-10 20:00:38 +01:00
if ( vcr & & vcr - > Contains ( " performance_data " ) ) {
vperf = vcr - > Get ( " performance_data " ) ;
if ( vperf )
vcr - > Remove ( " performance_data " ) ;
Deserialize ( cr , vcr , true ) ;
}
2016-09-13 22:14:11 +02:00
}
2015-10-19 17:31:18 +02:00
2016-09-13 22:14:11 +02:00
if ( ! cr )
return Empty ;
2015-10-19 17:31:18 +02:00
2018-01-11 11:17:38 +01:00
ArrayData rperf ;
2015-10-19 17:31:18 +02:00
if ( vperf ) {
ObjectLock olock ( vperf ) ;
2016-08-25 06:19:44 +02:00
for ( const Value & vp : vperf ) {
2015-10-19 17:31:18 +02:00
Value p ;
if ( vp . IsObjectType < Dictionary > ( ) ) {
PerfdataValue : : Ptr val = new PerfdataValue ( ) ;
Deserialize ( val , vp , true ) ;
2018-01-11 11:17:38 +01:00
rperf . push_back ( val ) ;
2015-10-19 17:31:18 +02:00
} else
2018-01-11 11:17:38 +01:00
rperf . push_back ( vp ) ;
2015-10-19 17:31:18 +02:00
}
}
2018-01-11 11:17:38 +01:00
cr - > SetPerformanceData ( new Array ( std : : move ( rperf ) ) ) ;
2015-10-19 17:31:18 +02:00
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) & & endpoint ! = checkable - > GetCommandEndpoint ( ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'check result' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2016-07-19 18:32:01 +02:00
if ( ! checkable - > IsPaused ( ) & & Zone : : GetLocalZone ( ) = = checkable - > GetZone ( ) & & endpoint = = checkable - > GetCommandEndpoint ( ) )
2015-10-19 17:31:18 +02:00
checkable - > ProcessCheckResult ( cr ) ;
else
checkable - > ProcessCheckResult ( cr , origin ) ;
return Empty ;
}
void ClusterEvents : : NextCheckChangedHandler ( const Checkable : : Ptr & checkable , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " next_check " , checkable - > GetNextCheck ( ) ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetNextCheck " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : NextCheckChangedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'next check changed' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'next check changed' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2016-08-04 10:12:55 +02:00
double nextCheck = params - > Get ( " next_check " ) ;
if ( nextCheck < Application : : GetStartTime ( ) + 60 )
return Empty ;
2015-10-19 17:31:18 +02:00
checkable - > SetNextCheck ( params - > Get ( " next_check " ) , false , origin ) ;
return Empty ;
}
2020-03-05 15:34:12 +01:00
void ClusterEvents : : LastCheckStartedChangedHandler ( const Checkable : : Ptr & checkable , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " last_check_started " , checkable - > GetLastCheckStarted ( ) ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetLastCheckStarted " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : LastCheckStartedChangedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
< < " Discarding 'last_check_started changed' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) ) {
Log ( LogNotice , " ClusterEvents " )
< < " Discarding 'last_check_started changed' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
return Empty ;
}
checkable - > SetLastCheckStarted ( params - > Get ( " last_check_started " ) , false , origin ) ;
return Empty ;
}
2019-07-02 11:23:16 +02:00
void ClusterEvents : : SuppressedNotificationsChangedHandler ( const Checkable : : Ptr & checkable , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " suppressed_notifications " , checkable - > GetSuppressedNotifications ( ) ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetSuppressedNotifications " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : SuppressedNotificationsChangedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
< < " Discarding 'suppressed notifications changed' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) ) {
Log ( LogNotice , " ClusterEvents " )
< < " Discarding 'suppressed notifications changed' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
return Empty ;
}
checkable - > SetSuppressedNotifications ( params - > Get ( " suppressed_notifications " ) , false , origin ) ;
2020-07-29 17:13:41 +02:00
return Empty ;
}
void ClusterEvents : : SuppressedNotificationTypesChangedHandler ( const Notification : : Ptr & notification , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " notification " , notification - > GetName ( ) ) ;
params - > Set ( " suppressed_notifications " , notification - > GetSuppressedNotifications ( ) ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetSuppressedNotificationTypes " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , notification , message , true ) ;
}
Value ClusterEvents : : SuppressedNotificationTypesChangedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
< < " Discarding 'suppressed notifications changed' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
return Empty ;
}
auto notification ( Notification : : GetByName ( params - > Get ( " notification " ) ) ) ;
if ( ! notification )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( notification ) ) {
Log ( LogNotice , " ClusterEvents " )
< < " Discarding 'suppressed notification types changed' message for notification ' " < < notification - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
return Empty ;
}
notification - > SetSuppressedNotifications ( params - > Get ( " suppressed_notifications " ) , false , origin ) ;
2019-07-02 11:23:16 +02:00
return Empty ;
}
2015-10-19 17:31:18 +02:00
void ClusterEvents : : NextNotificationChangedHandler ( const Notification : : Ptr & notification , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " notification " , notification - > GetName ( ) ) ;
params - > Set ( " next_notification " , notification - > GetNextNotification ( ) ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetNextNotification " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , notification , message , true ) ;
}
Value ClusterEvents : : NextNotificationChangedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'next notification changed' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
Notification : : Ptr notification = Notification : : GetByName ( params - > Get ( " notification " ) ) ;
if ( ! notification )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( notification ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'next notification changed' message for notification ' " < < notification - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2016-08-04 10:12:55 +02:00
double nextNotification = params - > Get ( " next_notification " ) ;
if ( nextNotification < Utility : : GetTime ( ) )
return Empty ;
notification - > SetNextNotification ( nextNotification , false , origin ) ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
void ClusterEvents : : ForceNextCheckChangedHandler ( const Checkable : : Ptr & checkable , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " forced " , checkable - > GetForceNextCheck ( ) ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetForceNextCheck " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : ForceNextCheckChangedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'force next check changed' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'force next check' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
checkable - > SetForceNextCheck ( params - > Get ( " forced " ) , false , origin ) ;
return Empty ;
}
void ClusterEvents : : ForceNextNotificationChangedHandler ( const Checkable : : Ptr & checkable , const MessageOrigin : : Ptr & origin )
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " forced " , checkable - > GetForceNextNotification ( ) ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetForceNextNotification " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : ForceNextNotificationChangedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'force next notification changed' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'force next notification' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
checkable - > SetForceNextNotification ( params - > Get ( " forced " ) , false , origin ) ;
return Empty ;
}
void ClusterEvents : : AcknowledgementSetHandler ( const Checkable : : Ptr & checkable ,
2017-12-19 15:50:05 +01:00
const String & author , const String & comment , AcknowledgementType type ,
2019-12-04 15:19:03 +01:00
bool notify , bool persistent , double changeTime , double expiry , const MessageOrigin : : Ptr & origin )
2015-10-19 17:31:18 +02:00
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " author " , author ) ;
params - > Set ( " comment " , comment ) ;
params - > Set ( " acktype " , type ) ;
params - > Set ( " notify " , notify ) ;
2019-01-28 17:29:46 +01:00
params - > Set ( " persistent " , persistent ) ;
2015-10-19 17:31:18 +02:00
params - > Set ( " expiry " , expiry ) ;
2019-12-04 15:19:03 +01:00
params - > Set ( " change_time " , changeTime ) ;
2015-10-19 17:31:18 +02:00
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::SetAcknowledgement " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : AcknowledgementSetAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'acknowledgement set' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'acknowledgement set' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2019-12-05 11:08:16 +01:00
ObjectLock oLock ( checkable ) ;
if ( checkable - > IsAcknowledged ( ) ) {
Log ( LogWarning , " ClusterEvents " )
< < " Discarding 'acknowledgement set' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Checkable is already acknowledged. " ;
return Empty ;
}
2015-10-19 17:31:18 +02:00
checkable - > AcknowledgeProblem ( params - > Get ( " author " ) , params - > Get ( " comment " ) ,
2017-12-19 15:50:05 +01:00
static_cast < AcknowledgementType > ( static_cast < int > ( params - > Get ( " acktype " ) ) ) ,
2019-12-04 15:19:03 +01:00
params - > Get ( " notify " ) , params - > Get ( " persistent " ) , params - > Get ( " change_time " ) , params - > Get ( " expiry " ) , origin ) ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2019-12-04 15:19:03 +01:00
void ClusterEvents : : AcknowledgementClearedHandler ( const Checkable : : Ptr & checkable , const String & removedBy , double changeTime , const MessageOrigin : : Ptr & origin )
2015-10-19 17:31:18 +02:00
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
2019-11-28 17:46:12 +01:00
params - > Set ( " author " , removedBy ) ;
2019-12-04 15:19:03 +01:00
params - > Set ( " change_time " , changeTime ) ;
2015-10-19 17:31:18 +02:00
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::ClearAcknowledgement " ) ;
message - > Set ( " params " , params ) ;
listener - > RelayMessage ( origin , checkable , message , true ) ;
}
Value ClusterEvents : : AcknowledgementClearedAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'acknowledgement cleared' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & ! origin - > FromZone - > CanAccessObject ( checkable ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'acknowledgement cleared' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2019-12-04 15:19:03 +01:00
checkable - > ClearAcknowledgement ( params - > Get ( " author " ) , params - > Get ( " change_time " ) , origin ) ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
Value ClusterEvents : : ExecuteCommandAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
2018-01-16 10:40:08 +01:00
EnqueueCheck ( origin , params ) ;
2015-10-19 17:31:18 +02:00
return Empty ;
}
2016-06-07 12:44:12 +02:00
void ClusterEvents : : SendNotificationsHandler ( const Checkable : : Ptr & checkable , NotificationType type ,
2017-12-19 15:50:05 +01:00
const CheckResult : : Ptr & cr , const String & author , const String & text , const MessageOrigin : : Ptr & origin )
2016-06-07 12:44:12 +02:00
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Dictionary : : Ptr message = MakeCheckResultMessage ( checkable , cr ) ;
message - > Set ( " method " , " event::SendNotifications " ) ;
Dictionary : : Ptr params = message - > Get ( " params " ) ;
params - > Set ( " type " , type ) ;
params - > Set ( " author " , author ) ;
params - > Set ( " text " , text ) ;
2017-11-30 08:36:35 +01:00
listener - > RelayMessage ( origin , nullptr , message , true ) ;
2016-06-07 12:44:12 +02:00
}
Value ClusterEvents : : SendNotificationsAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'send notification' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2016-06-07 12:44:12 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
2016-06-13 11:13:25 +02:00
if ( origin - > FromZone & & origin - > FromZone ! = Zone : : GetLocalZone ( ) ) {
2016-06-07 12:44:12 +02:00
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'send custom notification' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2016-06-07 12:44:12 +02:00
return Empty ;
}
2016-09-13 22:14:11 +02:00
CheckResult : : Ptr cr ;
2016-11-10 20:00:38 +01:00
Array : : Ptr vperf ;
2016-06-07 12:44:12 +02:00
2016-09-13 22:14:11 +02:00
if ( params - > Contains ( " cr " ) ) {
cr = new CheckResult ( ) ;
Dictionary : : Ptr vcr = params - > Get ( " cr " ) ;
2016-11-10 20:00:38 +01:00
if ( vcr & & vcr - > Contains ( " performance_data " ) ) {
vperf = vcr - > Get ( " performance_data " ) ;
if ( vperf )
vcr - > Remove ( " performance_data " ) ;
Deserialize ( cr , vcr , true ) ;
}
2016-09-13 22:14:11 +02:00
}
2016-06-07 12:44:12 +02:00
NotificationType type = static_cast < NotificationType > ( static_cast < int > ( params - > Get ( " type " ) ) ) ;
String author = params - > Get ( " author " ) ;
String text = params - > Get ( " text " ) ;
Checkable : : OnNotificationsRequested ( checkable , type , cr , author , text , origin ) ;
return Empty ;
}
2016-06-15 11:27:01 +02:00
void ClusterEvents : : NotificationSentUserHandler ( const Notification : : Ptr & notification , const Checkable : : Ptr & checkable , const User : : Ptr & user ,
2020-01-07 14:20:59 +01:00
NotificationType notificationType , const CheckResult : : Ptr & cr , const String & author , const String & commentText , const String & command ,
2017-12-19 15:50:05 +01:00
const MessageOrigin : : Ptr & origin )
2016-06-15 11:27:01 +02:00
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " notification " , notification - > GetName ( ) ) ;
params - > Set ( " user " , user - > GetName ( ) ) ;
params - > Set ( " type " , notificationType ) ;
params - > Set ( " cr " , Serialize ( cr ) ) ;
params - > Set ( " author " , author ) ;
params - > Set ( " text " , commentText ) ;
params - > Set ( " command " , command ) ;
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
message - > Set ( " method " , " event::NotificationSentUser " ) ;
message - > Set ( " params " , params ) ;
2017-11-30 08:36:35 +01:00
listener - > RelayMessage ( origin , nullptr , message , true ) ;
2016-06-15 11:27:01 +02:00
}
Value ClusterEvents : : NotificationSentUserAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'sent notification to user' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2016-06-15 11:27:01 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & origin - > FromZone ! = Zone : : GetLocalZone ( ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'send notification to user' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2016-06-15 11:27:01 +02:00
return Empty ;
}
2016-09-13 22:14:11 +02:00
CheckResult : : Ptr cr ;
2016-11-10 20:00:38 +01:00
Array : : Ptr vperf ;
2016-06-15 11:27:01 +02:00
2016-09-13 22:14:11 +02:00
if ( params - > Contains ( " cr " ) ) {
cr = new CheckResult ( ) ;
Dictionary : : Ptr vcr = params - > Get ( " cr " ) ;
2016-11-10 20:00:38 +01:00
if ( vcr & & vcr - > Contains ( " performance_data " ) ) {
vperf = vcr - > Get ( " performance_data " ) ;
if ( vperf )
vcr - > Remove ( " performance_data " ) ;
Deserialize ( cr , vcr , true ) ;
}
2016-09-13 22:14:11 +02:00
}
2016-06-15 11:27:01 +02:00
NotificationType type = static_cast < NotificationType > ( static_cast < int > ( params - > Get ( " type " ) ) ) ;
String author = params - > Get ( " author " ) ;
String text = params - > Get ( " text " ) ;
Notification : : Ptr notification = Notification : : GetByName ( params - > Get ( " notification " ) ) ;
if ( ! notification )
return Empty ;
User : : Ptr user = User : : GetByName ( params - > Get ( " user " ) ) ;
if ( ! user )
return Empty ;
String command = params - > Get ( " command " ) ;
2020-01-07 14:20:59 +01:00
Checkable : : OnNotificationSentToUser ( notification , checkable , user , type , cr , author , text , command , origin ) ;
2016-06-15 11:27:01 +02:00
return Empty ;
}
2016-08-15 17:26:01 +02:00
void ClusterEvents : : NotificationSentToAllUsersHandler ( const Notification : : Ptr & notification , const Checkable : : Ptr & checkable , const std : : set < User : : Ptr > & users ,
2017-12-19 15:50:05 +01:00
NotificationType notificationType , const CheckResult : : Ptr & cr , const String & author , const String & commentText , const MessageOrigin : : Ptr & origin )
2016-06-15 11:27:01 +02:00
{
ApiListener : : Ptr listener = ApiListener : : GetInstance ( ) ;
if ( ! listener )
return ;
Host : : Ptr host ;
Service : : Ptr service ;
tie ( host , service ) = GetHostService ( checkable ) ;
Dictionary : : Ptr params = new Dictionary ( ) ;
params - > Set ( " host " , host - > GetName ( ) ) ;
if ( service )
params - > Set ( " service " , service - > GetShortName ( ) ) ;
params - > Set ( " notification " , notification - > GetName ( ) ) ;
2018-01-11 11:17:38 +01:00
ArrayData ausers ;
2016-08-25 06:19:44 +02:00
for ( const User : : Ptr & user : users ) {
2018-01-11 11:17:38 +01:00
ausers . push_back ( user - > GetName ( ) ) ;
2016-08-22 10:47:09 +02:00
}
2018-01-11 11:17:38 +01:00
params - > Set ( " users " , new Array ( std : : move ( ausers ) ) ) ;
2016-06-15 11:27:01 +02:00
params - > Set ( " type " , notificationType ) ;
params - > Set ( " cr " , Serialize ( cr ) ) ;
params - > Set ( " author " , author ) ;
params - > Set ( " text " , commentText ) ;
params - > Set ( " last_notification " , notification - > GetLastNotification ( ) ) ;
2016-08-05 06:53:06 +02:00
params - > Set ( " next_notification " , notification - > GetNextNotification ( ) ) ;
2016-06-15 11:27:01 +02:00
params - > Set ( " notification_number " , notification - > GetNotificationNumber ( ) ) ;
params - > Set ( " last_problem_notification " , notification - > GetLastProblemNotification ( ) ) ;
2016-08-15 18:32:51 +02:00
params - > Set ( " no_more_notifications " , notification - > GetNoMoreNotifications ( ) ) ;
2016-06-15 11:27:01 +02:00
Dictionary : : Ptr message = new Dictionary ( ) ;
message - > Set ( " jsonrpc " , " 2.0 " ) ;
2016-08-16 09:30:10 +02:00
message - > Set ( " method " , " event::NotificationSentToAllUsers " ) ;
2016-06-15 11:27:01 +02:00
message - > Set ( " params " , params ) ;
2017-11-30 08:36:35 +01:00
listener - > RelayMessage ( origin , nullptr , message , true ) ;
2016-06-15 11:27:01 +02:00
}
2016-08-16 09:30:10 +02:00
Value ClusterEvents : : NotificationSentToAllUsersAPIHandler ( const MessageOrigin : : Ptr & origin , const Dictionary : : Ptr & params )
2016-06-15 11:27:01 +02:00
{
Endpoint : : Ptr endpoint = origin - > FromClient - > GetEndpoint ( ) ;
if ( ! endpoint ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'sent notification to all users' message from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Invalid endpoint origin (client not allowed). " ;
2016-06-15 11:27:01 +02:00
return Empty ;
}
Host : : Ptr host = Host : : GetByName ( params - > Get ( " host " ) ) ;
if ( ! host )
return Empty ;
Checkable : : Ptr checkable ;
if ( params - > Contains ( " service " ) )
checkable = host - > GetServiceByShortName ( params - > Get ( " service " ) ) ;
else
checkable = host ;
if ( ! checkable )
return Empty ;
if ( origin - > FromZone & & origin - > FromZone ! = Zone : : GetLocalZone ( ) ) {
Log ( LogNotice , " ClusterEvents " )
2017-12-19 15:50:05 +01:00
< < " Discarding 'sent notification to all users' message for checkable ' " < < checkable - > GetName ( )
< < " ' from ' " < < origin - > FromClient - > GetIdentity ( ) < < " ': Unauthorized access. " ;
2016-06-15 11:27:01 +02:00
return Empty ;
}
2016-09-13 22:14:11 +02:00
CheckResult : : Ptr cr ;
2016-11-10 20:00:38 +01:00
Array : : Ptr vperf ;
2016-06-15 11:27:01 +02:00
2016-09-13 22:14:11 +02:00
if ( params - > Contains ( " cr " ) ) {
cr = new CheckResult ( ) ;
Dictionary : : Ptr vcr = params - > Get ( " cr " ) ;
2016-11-10 20:00:38 +01:00
if ( vcr & & vcr - > Contains ( " performance_data " ) ) {
vperf = vcr - > Get ( " performance_data " ) ;
if ( vperf )
vcr - > Remove ( " performance_data " ) ;
Deserialize ( cr , vcr , true ) ;
}
2016-09-13 22:14:11 +02:00
}
2016-06-15 11:27:01 +02:00
NotificationType type = static_cast < NotificationType > ( static_cast < int > ( params - > Get ( " type " ) ) ) ;
String author = params - > Get ( " author " ) ;
String text = params - > Get ( " text " ) ;
Notification : : Ptr notification = Notification : : GetByName ( params - > Get ( " notification " ) ) ;
if ( ! notification )
return Empty ;
Array : : Ptr ausers = params - > Get ( " users " ) ;
if ( ! ausers )
return Empty ;
std : : set < User : : Ptr > users ;
{
ObjectLock olock ( ausers ) ;
2016-08-25 06:19:44 +02:00
for ( const String & auser : ausers ) {
2016-06-15 11:27:01 +02:00
User : : Ptr user = User : : GetByName ( auser ) ;
if ( ! user )
continue ;
users . insert ( user ) ;
}
}
notification - > SetLastNotification ( params - > Get ( " last_notification " ) ) ;
notification - > SetNextNotification ( params - > Get ( " next_notification " ) ) ;
notification - > SetNotificationNumber ( params - > Get ( " notification_number " ) ) ;
notification - > SetLastProblemNotification ( params - > Get ( " last_problem_notification " ) ) ;
2016-08-15 18:32:51 +02:00
notification - > SetNoMoreNotifications ( params - > Get ( " no_more_notifications " ) ) ;
2016-08-22 10:47:09 +02:00
2018-01-11 11:17:38 +01:00
ArrayData notifiedProblemUsers ;
2016-08-25 06:19:44 +02:00
for ( const User : : Ptr & user : users ) {
2018-01-11 11:17:38 +01:00
notifiedProblemUsers . push_back ( user - > GetName ( ) ) ;
2016-08-22 10:47:09 +02:00
}
2018-01-11 11:17:38 +01:00
notification - > SetNotifiedProblemUsers ( new Array ( std : : move ( notifiedProblemUsers ) ) ) ;
2016-06-15 11:27:01 +02:00
Checkable : : OnNotificationSentToAllUsers ( notification , checkable , users , type , cr , author , text , origin ) ;
return Empty ;
}