remove middleware but check if prod in controller
This commit is contained in:
parent
d271bbdadb
commit
9b7972fdfd
|
@ -23,6 +23,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { getActionDefinitions as actionDefs } from "../../automations/actions"
|
import { getActionDefinitions as actionDefs } from "../../automations/actions"
|
||||||
import sdk from "../../sdk"
|
import sdk from "../../sdk"
|
||||||
|
import { isProdAppID } from "@budibase/backend-core/src/db"
|
||||||
|
|
||||||
async function getActionDefinitions() {
|
async function getActionDefinitions() {
|
||||||
return removeDeprecated(await actionDefs())
|
return removeDeprecated(await actionDefs())
|
||||||
|
@ -265,7 +266,6 @@ export async function trigger(ctx: BBContext) {
|
||||||
let automation = await db.get(ctx.params.id)
|
let automation = await db.get(ctx.params.id)
|
||||||
|
|
||||||
let hasCollectStep = sdk.automations.utils.checkForCollectStep(automation)
|
let hasCollectStep = sdk.automations.utils.checkForCollectStep(automation)
|
||||||
|
|
||||||
if (hasCollectStep) {
|
if (hasCollectStep) {
|
||||||
const response: AutomationResults = await triggers.externalTrigger(
|
const response: AutomationResults = await triggers.externalTrigger(
|
||||||
automation,
|
automation,
|
||||||
|
@ -281,6 +281,9 @@ export async function trigger(ctx: BBContext) {
|
||||||
)
|
)
|
||||||
ctx.body = collectedValue?.outputs
|
ctx.body = collectedValue?.outputs
|
||||||
} else {
|
} else {
|
||||||
|
if (ctx.appId && !isProdAppID(ctx.appId)) {
|
||||||
|
ctx.throw(400, "Only apps in production support this endpoint")
|
||||||
|
}
|
||||||
await triggers.externalTrigger(automation, {
|
await triggers.externalTrigger(automation, {
|
||||||
...ctx.request.body,
|
...ctx.request.body,
|
||||||
appId: ctx.appId,
|
appId: ctx.appId,
|
||||||
|
|
|
@ -65,7 +65,6 @@ router
|
||||||
)
|
)
|
||||||
.post(
|
.post(
|
||||||
"/api/automations/:id/trigger",
|
"/api/automations/:id/trigger",
|
||||||
appInfoMiddleware({ appType: AppType.PROD }),
|
|
||||||
paramResource("id"),
|
paramResource("id"),
|
||||||
authorized(
|
authorized(
|
||||||
permissions.PermissionType.AUTOMATION,
|
permissions.PermissionType.AUTOMATION,
|
||||||
|
|
Loading…
Reference in New Issue