Merge branch 'ent-9522-14213-llamada-api-add_event_comment-en-metaconsola-no-funciona' into 'develop'

fixed api function add comment for metaconsole pandora_enterprise#9522

pandora_enterprise#9522

See merge request artica/pandorafms!5121
This commit is contained in:
Jimmy Olano 2022-10-13 16:15:45 +00:00
commit d4bf526979
1 changed files with 39 additions and 12 deletions

View File

@ -13298,12 +13298,6 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3)
{ {
global $config; global $config;
if (defined('METACONSOLE')) {
$meta = true;
} else {
$meta = $other['data'][1];
}
if (!check_acl($config['id_user'], 0, 'EW')) { if (!check_acl($config['id_user'], 0, 'EW')) {
returnError('forbidden', 'string'); returnError('forbidden', 'string');
return; return;
@ -13314,13 +13308,46 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3)
return; return;
} else if ($other['type'] == 'array') { } else if ($other['type'] == 'array') {
$comment = $other['data'][0]; $comment = $other['data'][0];
$history = $other['data'][2];
$status = events_comment( $node_int = 0;
$id, if (is_metaconsole() === true) {
$comment, if (isset($other['data'][1]) === true
'Added comment' && empty($other['data'][1]) === false
); ) {
$node_int = $other['data'][1];
}
}
try {
if (is_metaconsole() === true
&& (int) $node_int > 0
) {
$node = new Node($node_int);
$node->connect();
}
$status = events_comment(
$id,
$comment,
'Added comment'
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $node_int > 0
) {
$node->disconnect();
}
$status = false;
} finally {
if (is_metaconsole() === true
&& $node_int > 0
) {
$node->disconnect();
}
}
if (is_error($status)) { if (is_error($status)) {
returnError( returnError(
'The event comment could not be added.' 'The event comment could not be added.'