From 9f1c2dd2c3f5ea9a1b194829bcd99be29df23c35 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 17 Jan 2024 13:02:00 -0500 Subject: [PATCH] fix(striker-ui-api): add recipient and alert-override switches to manage alerts --- .../mail-server => }/execManageAlerts.ts | 19 +++++++++++++++---- .../mail-server/createMailServer.ts | 2 +- .../mail-server/deleteMailServer.ts | 2 +- .../mail-server/updateMailServer.ts | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) rename striker-ui-api/src/lib/{request_handlers/mail-server => }/execManageAlerts.ts (78%) diff --git a/striker-ui-api/src/lib/request_handlers/mail-server/execManageAlerts.ts b/striker-ui-api/src/lib/execManageAlerts.ts similarity index 78% rename from striker-ui-api/src/lib/request_handlers/mail-server/execManageAlerts.ts rename to striker-ui-api/src/lib/execManageAlerts.ts index a611530e..a393d8a7 100644 --- a/striker-ui-api/src/lib/request_handlers/mail-server/execManageAlerts.ts +++ b/striker-ui-api/src/lib/execManageAlerts.ts @@ -1,12 +1,17 @@ import assert from 'assert'; import { spawnSync } from 'child_process'; -import { SERVER_PATHS } from '../../consts'; +import { SERVER_PATHS } from './consts'; -import { stdoutVar } from '../../shell'; +import { stdoutVar } from './shell'; const MAP_TO_FLAG_BUNDLE = { - 'alert-overrides': {}, + 'alert-overrides': { + '--alert-override-alert-level': 'level', + '--alert-override-host-uuid': 'hostUuid', + '--alert-override-recipient-uuid': 'recipientUuid', + '--alert-override-uuid': 'uuid', + }, 'mail-servers': { '--mail-server-address': 'address', '--mail-server-authentication': 'authentication', @@ -17,7 +22,13 @@ const MAP_TO_FLAG_BUNDLE = { '--mail-server-username': 'username', '--mail-server-uuid': 'uuid', }, - recipients: {}, + recipients: { + '--recipient-email': 'email', + '--recipient-language': 'language', + '--recipient-level': 'level', + '--recipient-name': 'name', + '--recipient-uuid': 'uuid', + }, }; export const execManageAlerts = ( diff --git a/striker-ui-api/src/lib/request_handlers/mail-server/createMailServer.ts b/striker-ui-api/src/lib/request_handlers/mail-server/createMailServer.ts index 3b9d80f9..b122a6c8 100644 --- a/striker-ui-api/src/lib/request_handlers/mail-server/createMailServer.ts +++ b/striker-ui-api/src/lib/request_handlers/mail-server/createMailServer.ts @@ -1,6 +1,6 @@ import { RequestHandler } from 'express'; -import { execManageAlerts } from './execManageAlerts'; +import { execManageAlerts } from '../../execManageAlerts'; import { getMailServerRequestBody } from './getMailServerRequestBody'; import { stderr, stdout } from '../../shell'; diff --git a/striker-ui-api/src/lib/request_handlers/mail-server/deleteMailServer.ts b/striker-ui-api/src/lib/request_handlers/mail-server/deleteMailServer.ts index dd552ff3..4323b7c3 100644 --- a/striker-ui-api/src/lib/request_handlers/mail-server/deleteMailServer.ts +++ b/striker-ui-api/src/lib/request_handlers/mail-server/deleteMailServer.ts @@ -1,6 +1,6 @@ import { RequestHandler } from 'express'; -import { execManageAlerts } from './execManageAlerts'; +import { execManageAlerts } from '../../execManageAlerts'; import { stderr } from '../../shell'; export const deleteMailServer: RequestHandler = ( diff --git a/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts b/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts index c45bd8cf..0c8cf858 100644 --- a/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts +++ b/striker-ui-api/src/lib/request_handlers/mail-server/updateMailServer.ts @@ -3,7 +3,7 @@ import { RequestHandler } from 'express'; import { REP_UUID } from '../../consts'; -import { execManageAlerts } from './execManageAlerts'; +import { execManageAlerts } from '../../execManageAlerts'; import { getMailServerRequestBody } from './getMailServerRequestBody'; import { stderr, stdout } from '../../shell';