Adding a mechanism for disabling cron jobs when an app is unpublished.
This commit is contained in:
parent
9d74aa2a44
commit
bb8fe8e941
|
@ -46,6 +46,7 @@ const {
|
|||
const { getTenantId, isMultiTenant } = require("@budibase/auth/tenancy")
|
||||
const { syncGlobalUsers } = require("./user")
|
||||
const { app: appCache } = require("@budibase/auth/cache")
|
||||
const { cleanupAutomations } = require("../../automations/utils")
|
||||
|
||||
const URL_REGEX_SLASH = /\/|\\/g
|
||||
|
||||
|
@ -319,6 +320,9 @@ exports.delete = async ctx => {
|
|||
if (!env.isTest() && !ctx.query.unpublish) {
|
||||
await deleteApp(ctx.params.appId)
|
||||
}
|
||||
if (ctx.query.unpublish) {
|
||||
await cleanupAutomations(ctx.params.appId)
|
||||
}
|
||||
// make sure the app/role doesn't stick around after the app has been deleted
|
||||
await removeAppFromUserRoles(ctx, ctx.params.appId)
|
||||
await appCache.invalidateAppMetadata(ctx.params.appId)
|
||||
|
|
|
@ -163,3 +163,12 @@ exports.checkForWebhooks = async ({ appId, oldAuto, newAuto }) => {
|
|||
}
|
||||
return newAuto
|
||||
}
|
||||
|
||||
/**
|
||||
* When removing an app/unpublishing it need to make sure automations are cleaned up (cron).
|
||||
* @param appId {string} the app that is being removed.
|
||||
* @return {Promise<void>} clean is complete if this succeeds.
|
||||
*/
|
||||
exports.cleanupAutomations = async appId => {
|
||||
await exports.disableAllCrons(appId)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue