fix; osc subscriptions (#392)

* style: fix typo

* refactor: convert to typescript

* refactor: convert to typescript

* refactor: create patch for osc subscriptions

* fix: issue with subscription invalidation
This commit is contained in:
Carlos Valente
2023-05-19 22:20:00 +02:00
committed by GitHub
parent 8bf223dee6
commit 6617eb1f0f
15 changed files with 227 additions and 106 deletions
@@ -269,6 +269,27 @@ export const getOSC = async (req, res) => {
res.status(200).send(osc);
};
export const postOscSubscriptions = async (req, res) => {
if (failEmptyObjects(req.body, res)) {
return;
}
try {
const oscSubscriptions = req.body;
const oscSettings = DataProvider.getOsc();
oscSettings.subscriptions = oscSubscriptions;
await DataProvider.setOsc(oscSettings);
// TODO: this update could be more granular, checking that relevant data was changed
const { message } = oscIntegration.init(oscSettings);
logger.info('RX', message);
res.send(oscSettings).status(200);
} catch (error) {
res.status(400).send(error);
}
};
// Create controller for POST request to '/ontime/osc'
// Returns ACK message
export const postOSC = async (req, res) => {