Live query CLP (#4387)
* Auth module refactoring in order to be reusable * Ensure cache controller is properly forwarded from helpers * Nits * Adds support for static validation * Adds support for CLP in Live query (no support for roles yet) * Adds e2e test to validate liveQuery hooks is properly called * Adds tests over LiveQueryController to ensure data is correctly transmitted * nits * Fixes for flow types * Removes usage of Parse.Promise * Use the Auth module for authentication and caches * Cleaner implementation of getting auth * Adds authCache that stores auth promises * Proper testing of the caching * nits
This commit is contained in:
14
src/rest.js
14
src/rest.js
@@ -101,7 +101,7 @@ function del(config, auth, className, objectId) {
|
||||
|
||||
enforceRoleSecurity('delete', className, auth);
|
||||
|
||||
var inflatedObject;
|
||||
let inflatedObject;
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
@@ -113,7 +113,7 @@ function del(config, auth, className, objectId) {
|
||||
if (hasTriggers || hasLiveQuery || className == '_Session') {
|
||||
return new RestQuery(config, auth, className, { objectId })
|
||||
.forWrite()
|
||||
.execute()
|
||||
.execute({ op: 'delete' })
|
||||
.then(response => {
|
||||
if (response && response.results && response.results.length) {
|
||||
const firstResult = response.results[0];
|
||||
@@ -172,7 +172,15 @@ function del(config, auth, className, objectId) {
|
||||
})
|
||||
.then(() => {
|
||||
// Notify LiveQuery server if possible
|
||||
config.liveQueryController.onAfterDelete(className, inflatedObject);
|
||||
config.database.loadSchema().then(schemaController => {
|
||||
const perms = schemaController.getClassLevelPermissions(className);
|
||||
config.liveQueryController.onAfterDelete(
|
||||
className,
|
||||
inflatedObject,
|
||||
null,
|
||||
perms
|
||||
);
|
||||
});
|
||||
return triggers.maybeRunTrigger(
|
||||
triggers.Types.afterDelete,
|
||||
auth,
|
||||
|
||||
Reference in New Issue
Block a user