fix: check automation usage in all rundowns before allowing delete

This commit is contained in:
Carlos Valente
2025-09-21 20:31:24 +02:00
committed by Alex Christoffer Rasmussen
parent cbd7bce106
commit bcabc50ad1
6 changed files with 178 additions and 75 deletions
@@ -4,8 +4,7 @@ import { Automation, AutomationSettings, ErrorResponse, Trigger } from 'ontime-t
import type { Request, Response } from 'express';
import { oscServer } from '../../adapters/OscAdapter.js';
import { getCurrentRundown, getRundownMetadata } from '../rundown/rundown.dao.js';
import { getDataProvider } from '../../classes/data-provider/DataProvider.js';
import * as automationDao from './automation.dao.js';
import * as automationService from './automation.service.js';
@@ -108,10 +107,8 @@ export async function editAutomation(req: Request, res: Response<Automation | Er
export async function deleteAutomation(req: Request, res: Response<void | ErrorResponse>) {
try {
const rundown = getCurrentRundown();
const { timedEventOrder } = getRundownMetadata();
await automationDao.deleteAutomation(rundown, timedEventOrder, req.params.id);
const projectRundowns = getDataProvider().getProjectRundowns();
await automationDao.deleteAutomation(projectRundowns, req.params.id);
res.status(204).send();
} catch (error) {
const message = getErrorMessage(error);