@@ -16,6 +16,8 @@ import type { FileEdge, RetentionRule } from '../generated/graphql';
16
16
import { RetentionRuleScope , RetentionUnit } from '../generated/graphql' ;
17
17
import { deleteFile } from '../database/file-storage' ;
18
18
import { DELETABLE_FILE_STATUSES , paginatedForPathWithEnrichment } from '../modules/internal/document/document-domain' ;
19
+ import { ENTITY_TYPE_IDENTITY_ORGANIZATION } from '../modules/organization/organization-types' ;
20
+ import { organizationDelete } from '../modules/organization/organization-domain' ;
19
21
import type { BasicStoreCommonEdge , StoreObject } from '../types/store' ;
20
22
import { ALREADY_DELETED_ERROR } from '../config/errors' ;
21
23
@@ -33,7 +35,12 @@ export const RETENTION_UNIT_VALUES = Object.values(RetentionUnit);
33
35
34
36
export const deleteElement = async ( context : AuthContext , scope : string , nodeId : string , nodeEntityType ?: string ) => {
35
37
if ( scope === 'knowledge' ) {
36
- await deleteElementById ( context , RETENTION_MANAGER_USER , nodeId , nodeEntityType , { forceDelete : true } ) ;
38
+ if ( nodeEntityType === ENTITY_TYPE_IDENTITY_ORGANIZATION ) {
39
+ // call organizationDelete which will ensure protections (for platform organization & members)
40
+ await organizationDelete ( context , RETENTION_MANAGER_USER , nodeId ) ;
41
+ } else {
42
+ await deleteElementById ( context , RETENTION_MANAGER_USER , nodeId , nodeEntityType , { forceDelete : true } ) ;
43
+ }
37
44
} else if ( scope === 'file' || scope === 'workbench' ) {
38
45
await deleteFile ( context , RETENTION_MANAGER_USER , nodeId ) ;
39
46
} else {
0 commit comments