Deleting a collection should detach associated drafts from it (#5082)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
@@ -582,9 +582,11 @@ router.post(
|
||||
document.collectionId = collectionId;
|
||||
}
|
||||
|
||||
const collection = await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(document.collectionId);
|
||||
const collection = document.collectionId
|
||||
? await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(document.collectionId)
|
||||
: undefined;
|
||||
|
||||
// if the collectionId was provided in the request and isn't valid then it will
|
||||
// be caught as a 403 on the authorize call below. Otherwise we're checking here
|
||||
@@ -938,6 +940,10 @@ router.post(
|
||||
ip: ctx.request.ip,
|
||||
});
|
||||
|
||||
if (!document.collectionId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(document.collectionId, { transaction });
|
||||
|
||||
Reference in New Issue
Block a user