fix: Cloud Code Trigger afterSave executes even if not set (#8520)

This commit is contained in:
Diamond Lewis
2023-05-11 19:39:54 -05:00
committed by GitHub
parent 4187a973cc
commit afd0515e20
2 changed files with 37 additions and 11 deletions

View File

@@ -1577,17 +1577,21 @@ RestWrite.prototype.runAfterSaveTrigger = function () {
const { originalObject, updatedObject } = this.buildParseObjects();
updatedObject._handleSaveResponse(this.response.response, this.response.status || 200);
this.config.database.loadSchema().then(schemaController => {
// Notifiy LiveQueryServer if possible
const perms = schemaController.getClassLevelPermissions(updatedObject.className);
this.config.liveQueryController.onAfterSave(
updatedObject.className,
updatedObject,
originalObject,
perms
);
});
if (hasLiveQuery) {
this.config.database.loadSchema().then(schemaController => {
// Notify LiveQueryServer if possible
const perms = schemaController.getClassLevelPermissions(updatedObject.className);
this.config.liveQueryController.onAfterSave(
updatedObject.className,
updatedObject,
originalObject,
perms
);
});
}
if (!hasAfterSaveHook) {
return Promise.resolve();
}
// Run afterSave trigger
return triggers
.maybeRunTrigger(