twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.52k stars 1.62k forks source link

Double creation of contacts when updating calendar event participants #6254

Closed bosiraphael closed 1 month ago

bosiraphael commented 1 month ago

Bug Description

The calendar module refactoring introduced a bug when calendar events are updated which causes contacts to be created twice, or events to not be assigned correctly to a participant.

Expected behavior

The calendar event participants should be updated correctly.

greptile-apps[bot] commented 1 month ago

To resolve the issue of double creation of contacts when updating calendar event participants, follow these steps:

  1. Review updateCalendarEventParticipantsAfterPeopleCreation Method:

    • File: /packages/twenty-server/src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service.ts
    • Ensure that this method does not trigger duplicate contact creation.
  2. Check createCompaniesAndContactsAndUpdateParticipants Method:

    • File: /packages/twenty-server/src/modules/connected-account/auto-companies-and-contacts-creation/services/create-company-and-contact.service.ts
    • Verify that this method is not called multiple times for the same event update.
  3. Inspect handleUpdatedEvent Method:

    • File: /packages/twenty-server/src/modules/calendar/listeners/calendar-channel.listener.ts
    • Ensure that the job to create a company and contact is not added multiple times when isContactAutoCreationEnabled is true.
  4. Examine handleCalendarEventParticipantMatchedEvent Method:

    • File: /packages/twenty-server/src/modules/calendar/listeners/calendar-event-participant.listener.ts
    • Confirm that timeline activities are not inserted multiple times for the same participant.
  5. Add Logging:

    • Add logging in the above methods to trace and ensure that each participant update and contact creation is only processed once.

References

/packages/twenty-server/src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service.ts /packages/twenty-server/src/modules/calendar/repositories/calendar-event-participant.repository.ts /packages/twenty-server/src/modules/calendar/services/google-calendar-sync/google-calendar-sync.service.ts /packages/twenty-server/src/modules/connected-account/auto-companies-and-contacts-creation/services/create-company-and-contact.service.ts /packages/twenty-server/src/modules/calendar/listeners/calendar-channel.listener.ts /packages/twenty-server/src/modules/calendar/listeners/calendar-event-participant.listener.ts

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/twentyhq/twenty/main) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)