Skip to content

Commit 26fc703

Browse files
committed
fix: Remove resources from collections when deleted
1 parent b46c80e commit 26fc703

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/uma/src/routes/ResourceRegistration.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ export class ResourceRegistrationRequestHandler extends HttpHandler {
175175
throw new ForbiddenHttpError(`${owner} is not the owner of this resource.`);
176176
}
177177

178+
// Remove registration
178179
await this.registrationStore.delete(parameters.id);
179180
this.logger.info(`Deleted resource ${parameters.id}.`);
180181

182+
// Remove references from ownership store
181183
const ownedResources = await this.ownershipStore.get(owner) ?? [];
182184
const idx = ownedResources.indexOf(parameters.id);
183185
if (idx >= 0) {
@@ -188,6 +190,12 @@ export class ResourceRegistrationRequestHandler extends HttpHandler {
188190
await this.ownershipStore.set(owner, ownedResources);
189191
}
190192
}
193+
194+
// Remove from collections
195+
const store = await this.policies.getStore()
196+
const remove = new Store(store.getQuads(parameters.id, ODRL.terms.partOf, null, null));
197+
await this.policies.removeData(remove);
198+
191199
return ({ status: 204 });
192200
}
193201

0 commit comments

Comments
 (0)