mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Support empty PATCH requests
This commit is contained in:
@@ -44,7 +44,7 @@ export class SparqlPatchPermissionsExtractor extends PermissionsExtractor {
|
||||
}
|
||||
|
||||
private isSupported(op: Algebra.Operation): boolean {
|
||||
if (op.type === Algebra.types.DELETE_INSERT) {
|
||||
if (this.isDeleteInsert(op) || this.isNop(op)) {
|
||||
return true;
|
||||
}
|
||||
if (op.type === Algebra.types.COMPOSITE_UPDATE) {
|
||||
@@ -57,7 +57,14 @@ export class SparqlPatchPermissionsExtractor extends PermissionsExtractor {
|
||||
return op.type === Algebra.types.DELETE_INSERT;
|
||||
}
|
||||
|
||||
private isNop(op: Algebra.Operation): op is Algebra.Nop {
|
||||
return op.type === Algebra.types.NOP;
|
||||
}
|
||||
|
||||
private needsAppend(update: Algebra.Operation): boolean {
|
||||
if (this.isNop(update)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isDeleteInsert(update)) {
|
||||
return Boolean(update.insert && update.insert.length > 0);
|
||||
}
|
||||
@@ -66,6 +73,9 @@ export class SparqlPatchPermissionsExtractor extends PermissionsExtractor {
|
||||
}
|
||||
|
||||
private needsWrite(update: Algebra.Operation): boolean {
|
||||
if (this.isNop(update)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isDeleteInsert(update)) {
|
||||
return Boolean(update.delete && update.delete.length > 0);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ export class SparqlUpdatePatchHandler extends PatchHandler {
|
||||
// Verify the patch
|
||||
const { source, identifier, patch } = input;
|
||||
const op = (patch as SparqlUpdatePatch).algebra;
|
||||
|
||||
// In case of a NOP we can skip everything
|
||||
if (op.type === Algebra.types.NOP) {
|
||||
return [];
|
||||
}
|
||||
|
||||
this.validateUpdate(op);
|
||||
|
||||
return this.applyPatch(source, identifier, op);
|
||||
|
||||
Reference in New Issue
Block a user