Execute notification command only if there is a source param

This commit is contained in:
Mattia Codato 2020-07-29 08:52:15 +02:00
parent a834b5cecd
commit edb5c47a9d
1 changed files with 7 additions and 9 deletions

View File

@ -306,7 +306,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
throw; throw;
} }
} }
} else if (command_type == "notification_command") { } else if (command_type == "notification_command" && params->Contains("source")) {
/* Get user */ /* Get user */
User::Ptr user = new User(); User::Ptr user = new User();
Dictionary::Ptr attrs = new Dictionary(); Dictionary::Ptr attrs = new Dictionary();
@ -332,14 +332,12 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
notificationCommand->Execute(notification, user, cr, NotificationType::NotificationCustom, notificationCommand->Execute(notification, user, cr, NotificationType::NotificationCustom,
author, ""); author, "");
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
if (params->Contains("source")) { String output = "Exception occurred during notification '" + notification->GetName()
String output = "Exception occurred during notification '" + notification->GetName() + "' for checkable '" + notification->GetCheckable()->GetName()
+ "' for checkable '" + notification->GetCheckable()->GetName() + "' and user '" + user->GetName() + "' using command '" + command + "': "
+ "' and user '" + user->GetName() + "' using command '" + command + "': " + DiagnosticInformation(ex, false);
+ DiagnosticInformation(ex, false); double now = Utility::GetTime();
double now = Utility::GetTime(); SendEventExecuteCommand(params, ServiceUnknown, output, now, now, listener, origin, sourceEndpoint);
SendEventExecuteCommand(params, ServiceUnknown, output, now, now, listener, origin, sourceEndpoint);
}
} }
} }
} }