Skip to content
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

[Bug] If I remove the email of a person, all the email participants are linked to that person #8846

Closed
bosiraphael opened this issue Dec 3, 2024 · 2 comments · Fixed by #8857
Assignees

Comments

@bosiraphael
Copy link
Contributor

Bug Description

If I remove the email of a person, all the email participants are linked to that person.

Expected behavior

Should just unlink the email associated to that person.

Technical inputs

Probably an error inside message-participant-person.listener.ts

@bosiraphael
Copy link
Contributor Author

In the frontend we can't modify an email to be empty
Image

@bosiraphael
Copy link
Contributor Author

bosiraphael commented Dec 3, 2024

This only happens when the user primary email is set to null. This can never happen via the frontend since there is validation, but this error appeared when a user set the email of a person to null via the API.
Normally, the text fields are non nullable, but due to a bug on the composite fields, emailPrimaryEmail and other text composite fields are nullable.

We listen to the changes on people emails to reassign the messageParticipants and the calendarEventParticipants to the right person, but inside match-participant.service on line 149, we do this:

const participantsToUpdate = await participantRepository.find({
      where: {
        handle,
      },
    });

But if handle is null, it selects all the participants.
To fix this, we should make all composite fields of type text non nullable and use Equal from typeorm to modify the query like this:

const participantsToUpdate = await participantRepository.find({
      where: {
        handle: Equal(handle)
      },
    });

@bosiraphael bosiraphael linked a pull request Dec 3, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from 🔖 Planned to ✅ Done in 🎯 Roadmap & Sprints Dec 3, 2024
mdrazak2001 pushed a commit to mdrazak2001/twenty that referenced this issue Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant