-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Emit company created event #12404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit company created event #12404
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Added event emission for company creation during email import to properly trigger workflows when companies are created via email/calendar sync.
- Added
workspaceEventEmitter.emitDatabaseBatchEvent()
increateCompanies()
to emit events for newly created companies - Integrated
ObjectMetadataEntity
to properly identify company metadata for event emission - Structured event payload to include company record ID, metadata, and properties for workflow triggers
- Maintains batch processing efficiency by emitting a single batch event for multiple companies
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I would like to validate something with @Weiko before merge if ok for you
const objectMetadata = await this.objectMetadataRepository.findOne({ | ||
where: { | ||
standardId: STANDARD_OBJECT_IDS.company, | ||
workspaceId, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using the cache instead of calling the db? @Weiko could it be a new standard?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, we don't have a good framework today to make this choice, loading the whole objectMetadataMap from cache instead of querying a single record has some trade off as well. Let's keep it like this for now, the query should be fast anyway
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:14707 This environment will automatically shut down when the PR is closed or after 5 hours. |
68e3f09
to
0e4aa36
Compare
Fixes twentyhq#12337 When importing emails, matched companies are added, but no event is triggered. Which means that workflows are not triggered. Adding the event. To test: - create a workflow that listens to company creation - import emails - make sure workflow has been triggered
Fixes twentyhq#12337 When importing emails, matched companies are added, but no event is triggered. Which means that workflows are not triggered. Adding the event. To test: - create a workflow that listens to company creation - import emails - make sure workflow has been triggered
Fixes #12337
When importing emails, matched companies are added, but no event is triggered. Which means that workflows are not triggered. Adding the event.
To test: