Skip to content

Commit

Permalink
fix(endpoint): Fix addValues endpoint when receiving from legacy OIbus
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerni10 committed Apr 24, 2023
1 parent ea1888f commit 45113fb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/web-server/controllers/engine.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@ const getSouth = (ctx) => {
* @return {void}
*/
const addValues = async (ctx) => {
const { name } = ctx.request.query
if (name && Array.isArray(ctx.request.body)) {
const { name, dataSourceId } = ctx.request.query
const dataSource = name || dataSourceId
if (dataSource && Array.isArray(ctx.request.body)) {
try {
ctx.app.engine.addValuesMessages += 1
ctx.app.engine.addValuesCount += ctx.request.body.length
await ctx.app.engine.addValues(name, ctx.request.body)
await ctx.app.engine.addValues(dataSource, ctx.request.body)
ctx.ok()
} catch (error) {
ctx.throw(500, `Unable to add ${ctx.request.body.length} from ${name}`)
ctx.throw(500, `Unable to add ${ctx.request.body.length} from ${dataSource}`)
}
} else {
throw ctx(400, 'Missing datasource name')
throw ctx.throw(400, 'Missing datasource name')
}
}

Expand Down

0 comments on commit 45113fb

Please sign in to comment.