Check if the node accept commands only if the origin is not local

This commit is contained in:
Mattia Codato 2020-07-21 16:33:52 +02:00
parent 05b1beb2ff
commit b4d6fe2c8d
1 changed files with 6 additions and 10 deletions

View File

@ -154,7 +154,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
};
}
if (!listener->GetAcceptCommands()) {
if (!listener->GetAcceptCommands() && !origin->IsLocal()) {
Log(LogWarning, "ApiListener")
<< "Ignoring command. '" << listener->GetName() << "' does not accept commands.";
@ -172,16 +172,12 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
executedParams->Set("start", now);
executedParams->Set("end", now);
if (origin->IsLocal()) {
ClusterEvents::ExecutedCommandAPIHandler(origin, executedParams);
} else {
Dictionary::Ptr executedMessage = new Dictionary();
executedMessage->Set("jsonrpc", "2.0");
executedMessage->Set("method", "event::ExecutedCommand");
executedMessage->Set("params", executedParams);
Dictionary::Ptr executedMessage = new Dictionary();
executedMessage->Set("jsonrpc", "2.0");
executedMessage->Set("method", "event::ExecutedCommand");
executedMessage->Set("params", executedParams);
listener->SyncSendMessage(sourceEndpoint, executedMessage);
}
listener->SyncSendMessage(sourceEndpoint, executedMessage);
} else {
Host::Ptr host = new Host();
Dictionary::Ptr attrs = new Dictionary();