From 16bdfb236eefba6e66146d5f0dd7107a41c0f409 Mon Sep 17 00:00:00 2001 From: nnamdifrankie Date: Mon, 16 Mar 2020 15:29:22 -0400 Subject: [PATCH] EMT-248: clean up code a tad --- .../plugins/ingest_manager/server/services/agents/acks.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ingest_manager/server/services/agents/acks.ts b/x-pack/plugins/ingest_manager/server/services/agents/acks.ts index e9464e7a62c7..892d8cdbe657 100644 --- a/x-pack/plugins/ingest_manager/server/services/agents/acks.ts +++ b/x-pack/plugins/ingest_manager/server/services/agents/acks.ts @@ -36,7 +36,7 @@ export async function acknowledgeAgentActions( const matchedUpdatedActions: AgentAction[] = []; agentEvents.forEach(agentEvent => { - if (ALLOWED_ACKNOWLEDGEMENT_TYPE.indexOf(agentEvent.type) < 0) { + if (!isAllowedType(agentEvent.type)) { throw Boom.badRequest(`${agentEvent.type} not allowed for acknowledgment only ACTION_RESULT`); } if (agentActionMap.has(agentEvent.action_id!)) { @@ -59,6 +59,10 @@ export async function acknowledgeAgentActions( return matchedUpdatedActions; } +function isAllowedType(eventType: string): boolean { + return ALLOWED_ACKNOWLEDGEMENT_TYPE.indexOf(eventType) >= 0; +} + export async function saveAgentEvents( soClient: SavedObjectsClientContract, events: AgentEvent[]