File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
backend/src/services/premium/enrichment Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { IServiceOptions } from '../../IServiceOptions'
1717import { EnrichmentParams , IEnrichmentResponse } from './types/organizationEnrichmentTypes'
1818import { getSearchSyncWorkerEmitter } from '@/serverless/utils/serviceSQS'
1919import SequelizeRepository from '@/database/repositories/sequelizeRepository'
20+ import OrganizationService from '@/services/organizationService'
2021
2122export default class OrganizationEnrichmentService extends LoggerBase {
2223 tenantId : string
@@ -163,6 +164,16 @@ export default class OrganizationEnrichmentService extends LoggerBase {
163164 }
164165
165166 delete org . identities
167+
168+ // Check for an organization with the same website exists
169+ const existingOrg = await OrganizationRepository . findByDomain ( org . website , this . options )
170+ const orgService = new OrganizationService ( this . options )
171+
172+ if ( existingOrg ) {
173+ await orgService . merge ( existingOrg . id , org . id )
174+ // remove the merged org from the list
175+ orgs = orgs . filter ( ( o ) => o . id !== org . id )
176+ }
166177 }
167178
168179 // TODO: Update cache
You can’t perform that action at this time.
0 commit comments