Remove deprecated EMAIL, PHONE, LINK (#7551)

In this PR:
- remove deprecated EMAIL, PHONE, LINK field types (except for Zapier
package as there is another work ongoing)
- remove composite currency filter on currencyCode, actor filter on name
and workspaceMember as the UX is not great yet
This commit is contained in:
Charles Bochet
2024-10-10 14:14:58 +02:00
committed by GitHub
parent a7d5aa933d
commit a58236e6da
87 changed files with 75 additions and 2746 deletions

View File

@ -32,10 +32,7 @@ export class CalendarEventParticipantPersonListener {
>,
) {
for (const eventPayload of payload.events) {
if (
eventPayload.properties.after.emails?.primaryEmail === null &&
eventPayload.properties.after.email === null
) {
if (eventPayload.properties.after.emails?.primaryEmail === null) {
continue;
}
@ -44,9 +41,7 @@ export class CalendarEventParticipantPersonListener {
CalendarEventParticipantMatchParticipantJob.name,
{
workspaceId: payload.workspaceId,
email:
eventPayload.properties.after.emails?.primaryEmail ??
eventPayload.properties.after.email, // TODO
email: eventPayload.properties.after.emails?.primaryEmail,
personId: eventPayload.recordId,
},
);
@ -64,16 +59,14 @@ export class CalendarEventParticipantPersonListener {
objectRecordUpdateEventChangedProperties(
eventPayload.properties.before,
eventPayload.properties.after,
).includes('email')
).includes('emails')
) {
// TODO: modify this job to take an array of participants to match
await this.messageQueueService.add<CalendarEventParticipantUnmatchParticipantJobData>(
CalendarEventParticipantUnmatchParticipantJob.name,
{
workspaceId: payload.workspaceId,
email:
eventPayload.properties.before.emails?.primaryEmail ??
eventPayload.properties.before.email,
email: eventPayload.properties.before.emails?.primaryEmail,
personId: eventPayload.recordId,
},
);
@ -82,9 +75,7 @@ export class CalendarEventParticipantPersonListener {
CalendarEventParticipantMatchParticipantJob.name,
{
workspaceId: payload.workspaceId,
email:
eventPayload.properties.after.emails?.primaryEmail ??
eventPayload.properties.after.email,
email: eventPayload.properties.after.emails?.primaryEmail,
personId: eventPayload.recordId,
},
);

View File

@ -1,7 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { isDefined } from 'class-validator';
import chunk from 'lodash.chunk';
import compact from 'lodash.compact';
import { Any, EntityManager, Repository } from 'typeorm';
@ -13,7 +12,6 @@ import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadat
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
import { WorkspaceEventEmitter } from 'src/engine/workspace-event-emitter/workspace-event-emitter';
import { PERSON_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
import { CONTACTS_CREATION_BATCH_SIZE } from 'src/modules/contact-creation-manager/constants/contacts-creation-batch-size.constant';
@ -54,13 +52,6 @@ export class CreateCompanyAndContactService {
return [];
}
const emailsFieldMetadata = await this.fieldMetadataRepository.findOne({
where: {
workspaceId: workspaceId,
standardId: PERSON_STANDARD_FIELD_IDS.emails,
},
});
const personRepository =
await this.twentyORMGlobalManager.getRepositoryForWorkspace(
workspaceId,
@ -89,16 +80,14 @@ export class CreateCompanyAndContactService {
}
const alreadyCreatedContacts = await personRepository.find({
where: isDefined(emailsFieldMetadata)
? {
emails: { primaryEmail: Any(uniqueHandles) },
}
: { email: Any(uniqueHandles) },
where: {
emails: { primaryEmail: Any(uniqueHandles) },
},
});
const alreadyCreatedContactEmails: string[] = isDefined(emailsFieldMetadata)
? alreadyCreatedContacts?.map(({ emails }) => emails?.primaryEmail)
: alreadyCreatedContacts?.map(({ email }) => email);
const alreadyCreatedContactEmails: string[] = alreadyCreatedContacts?.map(
({ emails }) => emails?.primaryEmail,
);
const filteredContactsToCreate = uniqueContacts.filter(
(participant) =>

View File

@ -7,7 +7,6 @@ import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/
import { ScopedWorkspaceContextFactory } from 'src/engine/twenty-orm/factories/scoped-workspace-context.factory';
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
import { WorkspaceEventEmitter } from 'src/engine/workspace-event-emitter/workspace-event-emitter';
import { PERSON_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { CalendarEventParticipantWorkspaceEntity } from 'src/modules/calendar/common/standard-objects/calendar-event-participant.workspace-entity';
import { MessageParticipantWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-participant.workspace-entity';
import { PersonWorkspaceEntity } from 'src/modules/person/standard-objects/person.workspace-entity';
@ -60,35 +59,19 @@ export class MatchParticipantService<
...new Set(participants.map((participant) => participant.handle)),
];
const emailsFieldMetadata = await this.fieldMetadataRepository.findOne({
where: {
workspaceId: workspaceId,
standardId: PERSON_STANDARD_FIELD_IDS.emails,
},
});
const personRepository =
await this.twentyORMManager.getRepository<PersonWorkspaceEntity>(
'person',
);
const people = emailsFieldMetadata
? await personRepository.find(
{
where: {
emails: Any(uniqueParticipantsHandles),
},
},
transactionManager,
)
: await personRepository.find(
{
where: {
email: Any(uniqueParticipantsHandles),
},
},
transactionManager,
);
const people = await personRepository.find(
{
where: {
emails: Any(uniqueParticipantsHandles),
},
},
transactionManager,
);
const workspaceMemberRepository =
await this.twentyORMManager.getRepository<WorkspaceMemberWorkspaceEntity>(
@ -105,10 +88,8 @@ export class MatchParticipantService<
);
for (const handle of uniqueParticipantsHandles) {
const person = people.find((person) =>
emailsFieldMetadata
? person.emails?.primaryEmail === handle
: person.email === handle,
const person = people.find(
(person) => person.emails?.primaryEmail === handle,
);
const workspaceMember = workspaceMembers.find(

View File

@ -32,10 +32,7 @@ export class MessageParticipantPersonListener {
>,
) {
for (const eventPayload of payload.events) {
if (
!eventPayload.properties.after.emails?.primaryEmail &&
!eventPayload.properties.after.email
) {
if (!eventPayload.properties.after.emails?.primaryEmail) {
continue;
}
@ -43,9 +40,7 @@ export class MessageParticipantPersonListener {
MessageParticipantMatchParticipantJob.name,
{
workspaceId: payload.workspaceId,
email:
eventPayload.properties.after.emails?.primaryEmail ??
eventPayload.properties.after.email,
email: eventPayload.properties.after.emails?.primaryEmail,
personId: eventPayload.recordId,
},
);
@ -60,10 +55,6 @@ export class MessageParticipantPersonListener {
) {
for (const eventPayload of payload.events) {
if (
objectRecordUpdateEventChangedProperties(
eventPayload.properties.before,
eventPayload.properties.after,
).includes('email') ||
objectRecordUpdateEventChangedProperties(
eventPayload.properties.before,
eventPayload.properties.after,
@ -73,9 +64,7 @@ export class MessageParticipantPersonListener {
MessageParticipantUnmatchParticipantJob.name,
{
workspaceId: payload.workspaceId,
email:
eventPayload.properties.before.emails?.primaryEmail ??
eventPayload.properties.before.email,
email: eventPayload.properties.before.emails?.primaryEmail,
personId: eventPayload.recordId,
},
);
@ -84,9 +73,7 @@ export class MessageParticipantPersonListener {
MessageParticipantMatchParticipantJob.name,
{
workspaceId: payload.workspaceId,
email:
eventPayload.properties.after.emails?.primaryEmail ??
eventPayload.properties.after.email,
email: eventPayload.properties.after.emails?.primaryEmail,
personId: eventPayload.recordId,
},
);

View File

@ -63,16 +63,6 @@ export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceIsNullable()
[NAME_FIELD_NAME]: FullNameMetadata | null;
@WorkspaceField({
standardId: PERSON_STANDARD_FIELD_IDS.email,
type: FieldMetadataType.EMAIL,
label: 'Email',
description: 'Contacts Email',
icon: 'IconMail',
})
@WorkspaceIsDeprecated()
email: string;
@WorkspaceField({
standardId: PERSON_STANDARD_FIELD_IDS.emails,
type: FieldMetadataType.EMAILS,