|
|
@ -1,15 +1,36 @@ |
|
|
|
import { RequestHandler } from 'express'; |
|
|
|
import { RequestHandler } from 'express'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { query } from '../../accessModule'; |
|
|
|
import { execManageAlerts } from '../../execManageAlerts'; |
|
|
|
import { execManageAlerts } from '../../execManageAlerts'; |
|
|
|
|
|
|
|
import { sanitize } from '../../sanitize'; |
|
|
|
import { stderr } from '../../shell'; |
|
|
|
import { stderr } from '../../shell'; |
|
|
|
|
|
|
|
|
|
|
|
export const deleteMailRecipient: RequestHandler< |
|
|
|
export const deleteMailRecipient: RequestHandler< |
|
|
|
MailRecipientParamsDictionary |
|
|
|
MailRecipientParamsDictionary |
|
|
|
> = (request, response) => { |
|
|
|
> = async (request, response) => { |
|
|
|
const { |
|
|
|
const { |
|
|
|
params: { uuid }, |
|
|
|
params: { uuid: rUuid }, |
|
|
|
} = request; |
|
|
|
} = request; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const uuid = sanitize(rUuid, 'string', { modifierType: 'sql' }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const rows = await query<[string][]>( |
|
|
|
|
|
|
|
`SELECT alert_override_uuid
|
|
|
|
|
|
|
|
FROM alert_overrides |
|
|
|
|
|
|
|
WHERE alert_override_alert_level != -1 |
|
|
|
|
|
|
|
AND alert_override_recipient_uuid = '${uuid}';`,
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rows.forEach(([u]) => |
|
|
|
|
|
|
|
execManageAlerts('alert-overrides', 'delete', { uuid: u }), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
stderr(`Failed to delete related alert override records; CAUSE ${error}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response.status(500).send(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
execManageAlerts('recipients', 'delete', { uuid }); |
|
|
|
execManageAlerts('recipients', 'delete', { uuid }); |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|