Fixing minor issue with automation quota updates.
This commit is contained in:
parent
e87fd9d0a5
commit
06100af834
|
@ -5,6 +5,7 @@ const {
|
|||
getAppId,
|
||||
updateAppId,
|
||||
doInAppContext,
|
||||
doInContext,
|
||||
} = require("./src/context")
|
||||
|
||||
module.exports = {
|
||||
|
@ -14,4 +15,5 @@ module.exports = {
|
|||
getAppId,
|
||||
updateAppId,
|
||||
doInAppContext,
|
||||
doInContext,
|
||||
}
|
||||
|
|
|
@ -139,6 +139,16 @@ const setAppTenantId = appId => {
|
|||
exports.updateTenantId(appTenantId)
|
||||
}
|
||||
|
||||
// gets the tenant ID from the app ID
|
||||
exports.doInContext = async (appId, task) => {
|
||||
const tenantId = exports.getTenantIDFromAppID(appId)
|
||||
return exports.doInTenant(tenantId, async () => {
|
||||
return exports.doInAppContext(appId, async () => {
|
||||
return task()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.doInAppContext = (appId, task, { forceNew } = {}) => {
|
||||
if (!appId) {
|
||||
throw new Error("appId is required")
|
||||
|
|
|
@ -8,7 +8,7 @@ import { MetadataTypes, WebhookType } from "../constants"
|
|||
import { getProdAppID, doWithDB } from "@budibase/backend-core/db"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import { getAppDB, getAppId } from "@budibase/backend-core/context"
|
||||
import { tenancy } from "@budibase/backend-core"
|
||||
import { context } from "@budibase/backend-core"
|
||||
import { quotas } from "@budibase/pro"
|
||||
|
||||
const WH_STEP_ID = definitions.WEBHOOK.stepId
|
||||
|
@ -22,8 +22,7 @@ export async function processEvent(job: any) {
|
|||
`${job.data.automation.appId} automation ${automationId} running`
|
||||
)
|
||||
// need to actually await these so that an error can be captured properly
|
||||
const tenantId = tenancy.getTenantIDFromAppID(job.data.event.appId)
|
||||
return await tenancy.doInTenant(tenantId, async () => {
|
||||
return await context.doInContext(job.data.event.appId, async () => {
|
||||
const runFn = () => Runner.run(job)
|
||||
return quotas.addAutomation(runFn, {
|
||||
automationId,
|
||||
|
|
Loading…
Reference in New Issue