mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): enhance logic
This commit is contained in:
@@ -52,14 +52,15 @@ export class ContentTypeRepository extends BaseRepository<
|
||||
>,
|
||||
criteria: TFilterQuery<ContentType>,
|
||||
) {
|
||||
const entityId: string = criteria._id as string;
|
||||
const associatedBlocks = await this.blockService?.findOne({
|
||||
'options.content.entity': entityId,
|
||||
});
|
||||
if (associatedBlocks) {
|
||||
throw new ForbiddenException(`Content type have blocks associated to it`);
|
||||
}
|
||||
if (criteria._id) {
|
||||
const associatedBlock = await this.blockService?.findOne({
|
||||
'options.content.entity': criteria._id,
|
||||
});
|
||||
if (associatedBlock) {
|
||||
throw new ForbiddenException(
|
||||
'Content type have blocks associated to it',
|
||||
);
|
||||
}
|
||||
await this.contentModel.deleteMany({ entity: criteria._id });
|
||||
} else {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user