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'
17
17
import { EnrichmentParams , IEnrichmentResponse } from './types/organizationEnrichmentTypes'
18
18
import { getSearchSyncWorkerEmitter } from '@/serverless/utils/serviceSQS'
19
19
import SequelizeRepository from '@/database/repositories/sequelizeRepository'
20
+ import OrganizationService from '@/services/organizationService'
20
21
21
22
export default class OrganizationEnrichmentService extends LoggerBase {
22
23
tenantId : string
@@ -163,6 +164,16 @@ export default class OrganizationEnrichmentService extends LoggerBase {
163
164
}
164
165
165
166
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
+ }
166
177
}
167
178
168
179
// TODO: Update cache
You can’t perform that action at this time.
0 commit comments