Skip to content

Commit

Permalink
EMT-248: clean up code a tad
Browse files Browse the repository at this point in the history
  • Loading branch information
nnamdifrankie committed Mar 16, 2020
1 parent 2bf3e10 commit 16bdfb2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion x-pack/plugins/ingest_manager/server/services/agents/acks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!)) {
Expand All @@ -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[]
Expand Down

0 comments on commit 16bdfb2

Please sign in to comment.