Skip to content

Commit

Permalink
fixup! refactor: migrate triggers to new service
Browse files Browse the repository at this point in the history
  • Loading branch information
cpvalente committed Jan 12, 2025
1 parent fdbc50f commit bcdf05d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps/server/src/api-data/automation/automation.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export function getAutomationSettings(): AutomationSettings {
return structuredClone(getDataProvider().getAutomation());
}

/**
* Gets the enabled status of the automations
*/
export function getAutomationsEnabled(): boolean {
return getAutomationSettings().enabledAutomations;
}

/**
* Gets a copy of the stored automations
*/
Expand Down
6 changes: 5 additions & 1 deletion apps/server/src/api-data/automation/automation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import { isOntimeCloud } from '../../externals.js';

import { emitOSC } from './clients/osc.client.js';
import { emitHTTP } from './clients/http.client.js';
import { getAutomations, getBlueprints } from './automation.dao.js';
import { getAutomations, getAutomationsEnabled, getBlueprints } from './automation.dao.js';

/**
* Exposes a method for triggering actions based on a TimerLifeCycle event
*/
export function triggerAutomations(event: TimerLifeCycle, state: RuntimeState) {
if (!getAutomationsEnabled()) {
return;
}

const automations = getAutomations();
const triggerAutomations = automations.filter((automation) => automation.trigger === event);
if (triggerAutomations.length === 0) {
Expand Down

0 comments on commit bcdf05d

Please sign in to comment.