4702 rename calendareventattendee to calendareventparticipant (#4761)

Closes #4702
This commit is contained in:
bosiraphael
2024-04-04 14:00:10 +02:00
committed by GitHub
parent 357882c395
commit 85caed3463
36 changed files with 305 additions and 330 deletions

View File

@ -5,25 +5,25 @@ import differenceWith from 'lodash.differencewith';
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { getFlattenedValuesAndValuesStringForBatchRawQuery } from 'src/modules/calendar/utils/getFlattenedValuesAndValuesStringForBatchRawQuery.util';
import {
CalendarEventAttendee,
CalendarEventAttendeeWithId,
CalendarEventParticipant,
CalendarEventParticipantWithId,
} from 'src/modules/calendar/types/calendar-event';
@Injectable()
export class CalendarEventAttendeeRepository {
export class CalendarEventParticipantRepository {
constructor(
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
) {}
public async getByIds(
calendarEventAttendeeIds: string[],
calendarEventParticipantIds: string[],
workspaceId: string,
transactionManager?: EntityManager,
): Promise<ObjectRecord<CalendarEventAttendeeObjectMetadata>[]> {
if (calendarEventAttendeeIds.length === 0) {
): Promise<ObjectRecord<CalendarEventParticipantObjectMetadata>[]> {
if (calendarEventParticipantIds.length === 0) {
return [];
}
@ -31,8 +31,8 @@ export class CalendarEventAttendeeRepository {
this.workspaceDataSourceService.getSchemaName(workspaceId);
return await this.workspaceDataSourceService.executeRawQuery(
`SELECT * FROM ${dataSourceSchema}."calendarEventAttendee" WHERE "id" = ANY($1)`,
[calendarEventAttendeeIds],
`SELECT * FROM ${dataSourceSchema}."calendarEventParticipant" WHERE "id" = ANY($1)`,
[calendarEventParticipantIds],
workspaceId,
transactionManager,
);
@ -42,7 +42,7 @@ export class CalendarEventAttendeeRepository {
calendarEventIds: string[],
workspaceId: string,
transactionManager?: EntityManager,
): Promise<ObjectRecord<CalendarEventAttendeeObjectMetadata>[]> {
): Promise<ObjectRecord<CalendarEventParticipantObjectMetadata>[]> {
if (calendarEventIds.length === 0) {
return [];
}
@ -51,7 +51,7 @@ export class CalendarEventAttendeeRepository {
this.workspaceDataSourceService.getSchemaName(workspaceId);
return await this.workspaceDataSourceService.executeRawQuery(
`SELECT * FROM ${dataSourceSchema}."calendarEventAttendee" WHERE "calendarEventId" = ANY($1)`,
`SELECT * FROM ${dataSourceSchema}."calendarEventParticipant" WHERE "calendarEventId" = ANY($1)`,
[calendarEventIds],
workspaceId,
transactionManager,
@ -59,11 +59,11 @@ export class CalendarEventAttendeeRepository {
}
public async deleteByIds(
calendarEventAttendeeIds: string[],
calendarEventParticipantIds: string[],
workspaceId: string,
transactionManager?: EntityManager,
): Promise<void> {
if (calendarEventAttendeeIds.length === 0) {
if (calendarEventParticipantIds.length === 0) {
return;
}
@ -71,20 +71,20 @@ export class CalendarEventAttendeeRepository {
this.workspaceDataSourceService.getSchemaName(workspaceId);
await this.workspaceDataSourceService.executeRawQuery(
`DELETE FROM ${dataSourceSchema}."calendarEventAttendee" WHERE "id" = ANY($1)`,
[calendarEventAttendeeIds],
`DELETE FROM ${dataSourceSchema}."calendarEventParticipant" WHERE "id" = ANY($1)`,
[calendarEventParticipantIds],
workspaceId,
transactionManager,
);
}
public async updateCalendarEventAttendees(
calendarEventAttendees: CalendarEventAttendee[],
public async updateCalendarEventParticipants(
calendarEventParticipants: CalendarEventParticipant[],
iCalUIDCalendarEventIdMap: Map<string, string>,
workspaceId: string,
transactionManager?: EntityManager,
): Promise<void> {
if (calendarEventAttendees.length === 0) {
if (calendarEventParticipants.length === 0) {
return;
}
@ -93,33 +93,36 @@ export class CalendarEventAttendeeRepository {
const calendarEventIds = Array.from(iCalUIDCalendarEventIdMap.values());
const existingCalendarEventAttendees = await this.getByCalendarEventIds(
const existingCalendarEventParticipants = await this.getByCalendarEventIds(
calendarEventIds,
workspaceId,
transactionManager,
);
const calendarEventAttendeesToDelete = differenceWith(
existingCalendarEventAttendees,
calendarEventAttendees,
(existingCalendarEventAttendee, calendarEventAttendee) =>
existingCalendarEventAttendee.handle === calendarEventAttendee.handle,
const calendarEventParticipantsToDelete = differenceWith(
existingCalendarEventParticipants,
calendarEventParticipants,
(existingCalendarEventParticipant, calendarEventParticipant) =>
existingCalendarEventParticipant.handle ===
calendarEventParticipant.handle,
);
await this.deleteByIds(
calendarEventAttendeesToDelete.map(
(calendarEventAttendee) => calendarEventAttendee.id,
calendarEventParticipantsToDelete.map(
(calendarEventParticipant) => calendarEventParticipant.id,
),
workspaceId,
transactionManager,
);
const values = calendarEventAttendees.map((calendarEventAttendee) => ({
...calendarEventAttendee,
calendarEventId: iCalUIDCalendarEventIdMap.get(
calendarEventAttendee.iCalUID,
),
}));
const values = calendarEventParticipants.map(
(calendarEventParticipant) => ({
...calendarEventParticipant,
calendarEventId: iCalUIDCalendarEventIdMap.get(
calendarEventParticipant.iCalUID,
),
}),
);
const { flattenedValues, valuesString } =
getFlattenedValuesAndValuesStringForBatchRawQuery(values, {
@ -127,17 +130,17 @@ export class CalendarEventAttendeeRepository {
handle: 'text',
displayName: 'text',
isOrganizer: 'boolean',
responseStatus: `${dataSourceSchema}."calendarEventAttendee_responsestatus_enum"`,
responseStatus: `${dataSourceSchema}."calendarEventParticipant_responsestatus_enum"`,
});
await this.workspaceDataSourceService.executeRawQuery(
`UPDATE ${dataSourceSchema}."calendarEventAttendee" AS "calendarEventAttendee"
`UPDATE ${dataSourceSchema}."calendarEventParticipant" AS "calendarEventParticipant"
SET "displayName" = "newValues"."displayName",
"isOrganizer" = "newValues"."isOrganizer",
"responseStatus" = "newValues"."responseStatus"
FROM (VALUES ${valuesString}) AS "newValues"("calendarEventId", "handle", "displayName", "isOrganizer", "responseStatus")
WHERE "calendarEventAttendee"."handle" = "newValues"."handle"
AND "calendarEventAttendee"."calendarEventId" = "newValues"."calendarEventId"`,
WHERE "calendarEventParticipant"."handle" = "newValues"."handle"
AND "calendarEventParticipant"."calendarEventId" = "newValues"."calendarEventId"`,
flattenedValues,
workspaceId,
transactionManager,
@ -147,7 +150,7 @@ export class CalendarEventAttendeeRepository {
public async getWithoutPersonIdAndWorkspaceMemberId(
workspaceId: string,
transactionManager?: EntityManager,
): Promise<CalendarEventAttendeeWithId[]> {
): Promise<CalendarEventParticipantWithId[]> {
if (!workspaceId) {
throw new Error('WorkspaceId is required');
}
@ -155,17 +158,17 @@ export class CalendarEventAttendeeRepository {
const dataSourceSchema =
this.workspaceDataSourceService.getSchemaName(workspaceId);
const calendarEventAttendees: CalendarEventAttendeeWithId[] =
const calendarEventParticipants: CalendarEventParticipantWithId[] =
await this.workspaceDataSourceService.executeRawQuery(
`SELECT "calendarEventAttendee".*
FROM ${dataSourceSchema}."calendarEventAttendee" AS "calendarEventAttendee"
WHERE "calendarEventAttendee"."personId" IS NULL
AND "calendarEventAttendee"."workspaceMemberId" IS NULL`,
`SELECT "calendarEventParticipant".*
FROM ${dataSourceSchema}."calendarEventParticipant" AS "calendarEventParticipant"
WHERE "calendarEventParticipant"."personId" IS NULL
AND "calendarEventParticipant"."workspaceMemberId" IS NULL`,
[],
workspaceId,
transactionManager,
);
return calendarEventAttendees;
return calendarEventParticipants;
}
}

View File

@ -7,7 +7,7 @@ import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metada
import { CalendarEventObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event.object-metadata';
import { getFlattenedValuesAndValuesStringForBatchRawQuery } from 'src/modules/calendar/utils/getFlattenedValuesAndValuesStringForBatchRawQuery.util';
import { CalendarEvent } from 'src/modules/calendar/types/calendar-event';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
@Injectable()
export class CalendarEventRepository {
@ -60,7 +60,7 @@ export class CalendarEventRepository {
offset: number,
workspaceId: string,
transactionManager?: EntityManager,
): Promise<ObjectRecord<CalendarEventAttendeeObjectMetadata>[]> {
): Promise<ObjectRecord<CalendarEventParticipantObjectMetadata>[]> {
const dataSourceSchema =
this.workspaceDataSourceService.getSchemaName(workspaceId);

View File

@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
import { CalendarEventAttendeeService } from 'src/modules/calendar/services/calendar-event-attendee/calendar-event-attendee.service';
import { CalendarEventParticipantService } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service';
import { AddPersonIdAndWorkspaceMemberIdModule } from 'src/modules/connected-account/services/add-person-id-and-workspace-member-id/add-person-id-and-workspace-member-id.module';
import { PersonObjectMetadata } from 'src/modules/person/standard-objects/person.object-metadata';
@ -12,7 +12,7 @@ import { PersonObjectMetadata } from 'src/modules/person/standard-objects/person
ObjectMetadataRepositoryModule.forFeature([PersonObjectMetadata]),
AddPersonIdAndWorkspaceMemberIdModule,
],
providers: [CalendarEventAttendeeService],
exports: [CalendarEventAttendeeService],
providers: [CalendarEventParticipantService],
exports: [CalendarEventParticipantService],
})
export class CalendarEventAttendeeModule {}
export class CalendarEventParticipantModule {}

View File

@ -8,13 +8,13 @@ import { PersonObjectMetadata } from 'src/modules/person/standard-objects/person
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
import { getFlattenedValuesAndValuesStringForBatchRawQuery } from 'src/modules/calendar/utils/getFlattenedValuesAndValuesStringForBatchRawQuery.util';
import {
CalendarEventAttendee,
CalendarEventAttendeeWithId,
CalendarEventParticipant,
CalendarEventParticipantWithId,
} from 'src/modules/calendar/types/calendar-event';
import { AddPersonIdAndWorkspaceMemberIdService } from 'src/modules/connected-account/services/add-person-id-and-workspace-member-id/add-person-id-and-workspace-member-id.service';
@Injectable()
export class CalendarEventAttendeeService {
export class CalendarEventParticipantService {
constructor(
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
@InjectObjectMetadataRepository(PersonObjectMetadata)
@ -22,36 +22,38 @@ export class CalendarEventAttendeeService {
private readonly addPersonIdAndWorkspaceMemberIdService: AddPersonIdAndWorkspaceMemberIdService,
) {}
public async updateCalendarEventAttendeesAfterContactCreation(
attendees: CalendarEventAttendeeWithId[],
public async updateCalendarEventParticipantsAfterContactCreation(
participants: CalendarEventParticipantWithId[],
workspaceId: string,
transactionManager?: EntityManager,
): Promise<void> {
if (!attendees) return;
if (!participants) return;
const dataSourceSchema =
this.workspaceDataSourceService.getSchemaName(workspaceId);
const handles = attendees.map((attendee) => attendee.handle);
const handles = participants.map((participant) => participant.handle);
const attendeePersonIds = await this.personRepository.getByEmails(
const participantPersonIds = await this.personRepository.getByEmails(
handles,
workspaceId,
transactionManager,
);
const calendarEventAttendeesToUpdate = attendees.map((attendee) => ({
id: attendee.id,
personId: attendeePersonIds.find(
(e: { id: string; email: string }) => e.email === attendee.handle,
)?.id,
}));
const calendarEventParticipantsToUpdate = participants.map(
(participant) => ({
id: participant.id,
personId: participantPersonIds.find(
(e: { id: string; email: string }) => e.email === participant.handle,
)?.id,
}),
);
if (calendarEventAttendeesToUpdate.length === 0) return;
if (calendarEventParticipantsToUpdate.length === 0) return;
const { flattenedValues, valuesString } =
getFlattenedValuesAndValuesStringForBatchRawQuery(
calendarEventAttendeesToUpdate,
calendarEventParticipantsToUpdate,
{
id: 'uuid',
personId: 'uuid',
@ -59,50 +61,50 @@ export class CalendarEventAttendeeService {
);
await this.workspaceDataSourceService.executeRawQuery(
`UPDATE ${dataSourceSchema}."calendarEventAttendee" AS "calendarEventAttendee" SET "personId" = "data"."personId"
`UPDATE ${dataSourceSchema}."calendarEventParticipant" AS "calendarEventParticipant" SET "personId" = "data"."personId"
FROM (VALUES ${valuesString}) AS "data"("id", "personId")
WHERE "calendarEventAttendee"."id" = "data"."id"`,
WHERE "calendarEventParticipant"."id" = "data"."id"`,
flattenedValues,
workspaceId,
transactionManager,
);
}
public async saveCalendarEventAttendees(
calendarEventAttendees: CalendarEventAttendee[],
public async saveCalendarEventParticipants(
calendarEventParticipants: CalendarEventParticipant[],
workspaceId: string,
transactionManager?: EntityManager,
): Promise<void> {
if (calendarEventAttendees.length === 0) {
if (calendarEventParticipants.length === 0) {
return;
}
const dataSourceSchema =
this.workspaceDataSourceService.getSchemaName(workspaceId);
const calendarEventAttendeesToSave =
const calendarEventParticipantsToSave =
await this.addPersonIdAndWorkspaceMemberIdService.addPersonIdAndWorkspaceMemberId(
calendarEventAttendees,
calendarEventParticipants,
workspaceId,
transactionManager,
);
const { flattenedValues, valuesString } =
getFlattenedValuesAndValuesStringForBatchRawQuery(
calendarEventAttendeesToSave,
calendarEventParticipantsToSave,
{
calendarEventId: 'uuid',
handle: 'text',
displayName: 'text',
isOrganizer: 'boolean',
responseStatus: `${dataSourceSchema}."calendarEventAttendee_responsestatus_enum"`,
responseStatus: `${dataSourceSchema}."calendarEventParticipant_responsestatus_enum"`,
personId: 'uuid',
workspaceMemberId: 'uuid',
},
);
await this.workspaceDataSourceService.executeRawQuery(
`INSERT INTO ${dataSourceSchema}."calendarEventAttendee" ("calendarEventId", "handle", "displayName", "isOrganizer", "responseStatus", "personId", "workspaceMemberId") VALUES ${valuesString}`,
`INSERT INTO ${dataSourceSchema}."calendarEventParticipant" ("calendarEventId", "handle", "displayName", "isOrganizer", "responseStatus", "personId", "workspaceMemberId") VALUES ${valuesString}`,
flattenedValues,
workspaceId,
transactionManager,

View File

@ -4,12 +4,12 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
import { CalendarEventAttendeeModule } from 'src/modules/calendar/services/calendar-event-attendee/calendar-event-attendee.module';
import { CalendarEventParticipantModule } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.module';
import { GoogleCalendarFullSyncService } from 'src/modules/calendar/services/google-calendar-full-sync.service';
import { CalendarProvidersModule } from 'src/modules/calendar/services/providers/calendar-providers.module';
import { CalendarChannelEventAssociationObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel-event-association.object-metadata';
import { CalendarChannelObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel.object-metadata';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { CalendarEventObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event.object-metadata';
import { BlocklistObjectMetadata } from 'src/modules/connected-account/standard-objects/blocklist.object-metadata';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
@ -24,12 +24,12 @@ import { WorkspaceMemberObjectMetadata } from 'src/modules/workspace-member/stan
CalendarEventObjectMetadata,
CalendarChannelObjectMetadata,
CalendarChannelEventAssociationObjectMetadata,
CalendarEventAttendeeObjectMetadata,
CalendarEventParticipantObjectMetadata,
BlocklistObjectMetadata,
PersonObjectMetadata,
WorkspaceMemberObjectMetadata,
]),
CalendarEventAttendeeModule,
CalendarEventParticipantModule,
TypeOrmModule.forFeature([FeatureFlagEntity], 'core'),
WorkspaceDataSourceModule,
],

View File

@ -20,15 +20,15 @@ import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/work
import { CalendarEventRepository } from 'src/modules/calendar/repositories/calendar-event.repository';
import { formatGoogleCalendarEvent } from 'src/modules/calendar/utils/format-google-calendar-event.util';
import { GoogleCalendarFullSyncJobData } from 'src/modules/calendar/jobs/google-calendar-full-sync.job';
import { CalendarEventAttendeeRepository } from 'src/modules/calendar/repositories/calendar-event-attendee.repository';
import { CalendarEventParticipantRepository } from 'src/modules/calendar/repositories/calendar-event-participant.repository';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
import { CalendarEventObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event.object-metadata';
import { CalendarChannelObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel.object-metadata';
import { CalendarChannelEventAssociationObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel-event-association.object-metadata';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { BlocklistObjectMetadata } from 'src/modules/connected-account/standard-objects/blocklist.object-metadata';
import { CalendarEventAttendeeService } from 'src/modules/calendar/services/calendar-event-attendee/calendar-event-attendee.service';
import { CalendarEventParticipantService } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service';
@Injectable()
export class GoogleCalendarFullSyncService {
@ -48,15 +48,15 @@ export class GoogleCalendarFullSyncService {
CalendarChannelEventAssociationObjectMetadata,
)
private readonly calendarChannelEventAssociationRepository: CalendarChannelEventAssociationRepository,
@InjectObjectMetadataRepository(CalendarEventAttendeeObjectMetadata)
private readonly calendarEventAttendeesRepository: CalendarEventAttendeeRepository,
@InjectObjectMetadataRepository(CalendarEventParticipantObjectMetadata)
private readonly calendarEventParticipantsRepository: CalendarEventParticipantRepository,
@InjectObjectMetadataRepository(BlocklistObjectMetadata)
private readonly blocklistRepository: BlocklistRepository,
@InjectRepository(FeatureFlagEntity, 'core')
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
private readonly eventEmitter: EventEmitter2,
private readonly calendarEventAttendeesService: CalendarEventAttendeeService,
private readonly calendarEventParticipantsService: CalendarEventParticipantService,
) {}
public async startGoogleCalendarFullSync(
@ -197,10 +197,12 @@ export class GoogleCalendarFullSyncService {
}),
);
const attendeesToSave = eventsToSave.flatMap((event) => event.attendees);
const participantsToSave = eventsToSave.flatMap(
(event) => event.participants,
);
const attendeesToUpdate = eventsToUpdate.flatMap(
(event) => event.attendees,
const participantsToUpdate = eventsToUpdate.flatMap(
(event) => event.participants,
);
const iCalUIDCalendarEventIdMap =
@ -267,8 +269,8 @@ export class GoogleCalendarFullSyncService {
startTime = Date.now();
await this.calendarEventAttendeesService.saveCalendarEventAttendees(
attendeesToSave,
await this.calendarEventParticipantsService.saveCalendarEventParticipants(
participantsToSave,
workspaceId,
transactionManager,
);
@ -276,15 +278,15 @@ export class GoogleCalendarFullSyncService {
endTime = Date.now();
this.logger.log(
`google calendar full-sync for workspace ${workspaceId} and account ${connectedAccountId}: saving attendees in ${
`google calendar full-sync for workspace ${workspaceId} and account ${connectedAccountId}: saving participants in ${
endTime - startTime
}ms.`,
);
startTime = Date.now();
await this.calendarEventAttendeesRepository.updateCalendarEventAttendees(
attendeesToUpdate,
await this.calendarEventParticipantsRepository.updateCalendarEventParticipants(
participantsToUpdate,
iCalUIDCalendarEventIdMap,
workspaceId,
transactionManager,
@ -293,14 +295,14 @@ export class GoogleCalendarFullSyncService {
endTime = Date.now();
this.logger.log(
`google calendar full-sync for workspace ${workspaceId} and account ${connectedAccountId}: updating attendees in ${
`google calendar full-sync for workspace ${workspaceId} and account ${connectedAccountId}: updating participants in ${
endTime - startTime
}ms.`,
);
});
if (calendarChannel.isContactAutoCreationEnabled) {
const contactsToCreate = attendeesToSave;
const contactsToCreate = participantsToSave;
this.eventEmitter.emit(`createContacts`, {
workspaceId,

View File

@ -1,5 +1,5 @@
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { calendarEventAttendeeStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { calendarEventParticipantStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { standardObjectIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
import { FieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/gate.decorator';
@ -11,7 +11,7 @@ import { CalendarEventObjectMetadata } from 'src/modules/calendar/standard-objec
import { PersonObjectMetadata } from 'src/modules/person/standard-objects/person.object-metadata';
import { WorkspaceMemberObjectMetadata } from 'src/modules/workspace-member/standard-objects/workspace-member.object-metadata';
export enum CalendarEventAttendeeResponseStatus {
export enum CalendarEventParticipantResponseStatus {
NEEDS_ACTION = 'NEEDS_ACTION',
DECLINED = 'DECLINED',
TENTATIVE = 'TENTATIVE',
@ -19,20 +19,20 @@ export enum CalendarEventAttendeeResponseStatus {
}
@ObjectMetadata({
standardId: standardObjectIds.calendarEventAttendee,
namePlural: 'calendarEventAttendees',
labelSingular: 'Calendar event attendee',
labelPlural: 'Calendar event attendees',
description: 'Calendar event attendees',
standardId: standardObjectIds.calendarEventParticipant,
namePlural: 'calendarEventParticipants',
labelSingular: 'Calendar event participant',
labelPlural: 'Calendar event participants',
description: 'Calendar event participants',
icon: 'IconCalendar',
})
@IsSystem()
@Gate({
featureFlag: 'IS_CALENDAR_ENABLED',
})
export class CalendarEventAttendeeObjectMetadata extends BaseObjectMetadata {
export class CalendarEventParticipantObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({
standardId: calendarEventAttendeeStandardFieldIds.calendarEvent,
standardId: calendarEventParticipantStandardFieldIds.calendarEvent,
type: FieldMetadataType.RELATION,
label: 'Event ID',
description: 'Event ID',
@ -42,7 +42,7 @@ export class CalendarEventAttendeeObjectMetadata extends BaseObjectMetadata {
calendarEvent: CalendarEventObjectMetadata;
@FieldMetadata({
standardId: calendarEventAttendeeStandardFieldIds.handle,
standardId: calendarEventParticipantStandardFieldIds.handle,
type: FieldMetadataType.TEXT,
label: 'Handle',
description: 'Handle',
@ -51,7 +51,7 @@ export class CalendarEventAttendeeObjectMetadata extends BaseObjectMetadata {
handle: string;
@FieldMetadata({
standardId: calendarEventAttendeeStandardFieldIds.displayName,
standardId: calendarEventParticipantStandardFieldIds.displayName,
type: FieldMetadataType.TEXT,
label: 'Display Name',
description: 'Display Name',
@ -60,7 +60,7 @@ export class CalendarEventAttendeeObjectMetadata extends BaseObjectMetadata {
displayName: string;
@FieldMetadata({
standardId: calendarEventAttendeeStandardFieldIds.isOrganizer,
standardId: calendarEventParticipantStandardFieldIds.isOrganizer,
type: FieldMetadataType.BOOLEAN,
label: 'Is Organizer',
description: 'Is Organizer',
@ -70,43 +70,43 @@ export class CalendarEventAttendeeObjectMetadata extends BaseObjectMetadata {
isOrganizer: boolean;
@FieldMetadata({
standardId: calendarEventAttendeeStandardFieldIds.responseStatus,
standardId: calendarEventParticipantStandardFieldIds.responseStatus,
type: FieldMetadataType.SELECT,
label: 'Response Status',
description: 'Response Status',
icon: 'IconUser',
options: [
{
value: CalendarEventAttendeeResponseStatus.NEEDS_ACTION,
value: CalendarEventParticipantResponseStatus.NEEDS_ACTION,
label: 'Needs Action',
position: 0,
color: 'orange',
},
{
value: CalendarEventAttendeeResponseStatus.DECLINED,
value: CalendarEventParticipantResponseStatus.DECLINED,
label: 'Declined',
position: 1,
color: 'red',
},
{
value: CalendarEventAttendeeResponseStatus.TENTATIVE,
value: CalendarEventParticipantResponseStatus.TENTATIVE,
label: 'Tentative',
position: 2,
color: 'yellow',
},
{
value: CalendarEventAttendeeResponseStatus.ACCEPTED,
value: CalendarEventParticipantResponseStatus.ACCEPTED,
label: 'Accepted',
position: 3,
color: 'green',
},
],
defaultValue: `'${CalendarEventAttendeeResponseStatus.NEEDS_ACTION}'`,
defaultValue: `'${CalendarEventParticipantResponseStatus.NEEDS_ACTION}'`,
})
responseStatus: string;
@FieldMetadata({
standardId: calendarEventAttendeeStandardFieldIds.person,
standardId: calendarEventParticipantStandardFieldIds.person,
type: FieldMetadataType.RELATION,
label: 'Person',
description: 'Person',
@ -117,7 +117,7 @@ export class CalendarEventAttendeeObjectMetadata extends BaseObjectMetadata {
person: PersonObjectMetadata;
@FieldMetadata({
standardId: calendarEventAttendeeStandardFieldIds.workspaceMember,
standardId: calendarEventParticipantStandardFieldIds.workspaceMember,
type: FieldMetadataType.RELATION,
label: 'Workspace Member',
description: 'Workspace Member',

View File

@ -11,7 +11,7 @@ import { IsSystem } from 'src/engine/workspace-manager/workspace-sync-metadata/d
import { ObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/object-metadata.decorator';
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
import { CalendarChannelEventAssociationObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-channel-event-association.object-metadata';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { IsNullable } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-nullable.decorator';
import { standardObjectIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
import { calendarEventStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
@ -171,16 +171,16 @@ export class CalendarEventObjectMetadata extends BaseObjectMetadata {
calendarChannelEventAssociations: CalendarChannelEventAssociationObjectMetadata[];
@FieldMetadata({
standardId: calendarEventStandardFieldIds.eventAttendees,
standardId: calendarEventStandardFieldIds.eventParticipants,
type: FieldMetadataType.RELATION,
label: 'Event Attendees',
description: 'Event Attendees',
label: 'Event Participants',
description: 'Event Participants',
icon: 'IconUserCircle',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
inverseSideTarget: () => CalendarEventAttendeeObjectMetadata,
inverseSideTarget: () => CalendarEventParticipantObjectMetadata,
onDelete: RelationOnDeleteAction.CASCADE,
})
eventAttendees: CalendarEventAttendeeObjectMetadata[];
eventParticipants: CalendarEventParticipantObjectMetadata[];
}

View File

@ -1,4 +1,4 @@
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { CalendarEventObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event.object-metadata';
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
@ -7,16 +7,16 @@ export type CalendarEvent = Omit<
| 'createdAt'
| 'updatedAt'
| 'calendarChannelEventAssociations'
| 'calendarEventAttendees'
| 'eventAttendees'
| 'calendarEventParticipants'
| 'eventParticipants'
| 'conferenceLink'
> & {
conferenceLinkLabel: string;
conferenceLinkUrl: string;
};
export type CalendarEventAttendee = Omit<
ObjectRecord<CalendarEventAttendeeObjectMetadata>,
export type CalendarEventParticipant = Omit<
ObjectRecord<CalendarEventParticipantObjectMetadata>,
| 'id'
| 'createdAt'
| 'updatedAt'
@ -29,11 +29,11 @@ export type CalendarEventAttendee = Omit<
iCalUID: string;
};
export type CalendarEventWithAttendees = CalendarEvent & {
export type CalendarEventWithParticipants = CalendarEvent & {
externalId: string;
attendees: CalendarEventAttendee[];
participants: CalendarEventParticipant[];
};
export type CalendarEventAttendeeWithId = CalendarEventAttendee & {
export type CalendarEventParticipantWithId = CalendarEventParticipant & {
id: string;
};

View File

@ -1,24 +1,24 @@
import { calendar_v3 } from 'googleapis';
import { v4 } from 'uuid';
import { CalendarEventWithAttendees } from 'src/modules/calendar/types/calendar-event';
import { CalendarEventAttendeeResponseStatus } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantResponseStatus } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { CalendarEventWithParticipants } from 'src/modules/calendar/types/calendar-event';
export const formatGoogleCalendarEvent = (
event: calendar_v3.Schema$Event,
): CalendarEventWithAttendees => {
): CalendarEventWithParticipants => {
const id = v4();
const formatResponseStatus = (status: string | null | undefined) => {
switch (status) {
case 'accepted':
return CalendarEventAttendeeResponseStatus.ACCEPTED;
return CalendarEventParticipantResponseStatus.ACCEPTED;
case 'declined':
return CalendarEventAttendeeResponseStatus.DECLINED;
return CalendarEventParticipantResponseStatus.DECLINED;
case 'tentative':
return CalendarEventAttendeeResponseStatus.TENTATIVE;
return CalendarEventParticipantResponseStatus.TENTATIVE;
default:
return CalendarEventAttendeeResponseStatus.NEEDS_ACTION;
return CalendarEventParticipantResponseStatus.NEEDS_ACTION;
}
};
@ -40,7 +40,7 @@ export const formatGoogleCalendarEvent = (
conferenceLinkLabel: event.conferenceData?.entryPoints?.[0]?.uri ?? '',
conferenceLinkUrl: event.conferenceData?.entryPoints?.[0]?.uri ?? '',
recurringEventExternalId: event.recurringEventId ?? '',
attendees:
participants:
event.attendees?.map((attendee) => ({
calendarEventId: id,
iCalUID: event.iCalUID ?? '',

View File

@ -9,8 +9,8 @@ import { WorkspaceMemberObjectMetadata } from 'src/modules/workspace-member/stan
import { MessageParticipantModule } from 'src/modules/messaging/services/message-participant/message-participant.module';
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
import { CreateCompanyAndContactListener } from 'src/modules/connected-account/auto-companies-and-contacts-creation/listeners/create-company-and-contact.listener';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventAttendeeModule } from 'src/modules/calendar/services/calendar-event-attendee/calendar-event-attendee.module';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { CalendarEventParticipantModule } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.module';
@Module({
imports: [
@ -19,11 +19,11 @@ import { CalendarEventAttendeeModule } from 'src/modules/calendar/services/calen
ObjectMetadataRepositoryModule.forFeature([
PersonObjectMetadata,
WorkspaceMemberObjectMetadata,
CalendarEventAttendeeObjectMetadata,
CalendarEventParticipantObjectMetadata,
]),
MessageParticipantModule,
WorkspaceDataSourceModule,
CalendarEventAttendeeModule,
CalendarEventParticipantModule,
],
providers: [CreateCompanyAndContactService, CreateCompanyAndContactListener],
exports: [CreateCompanyAndContactService],

View File

@ -18,9 +18,9 @@ import { MessageParticipantRepository } from 'src/modules/messaging/repositories
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
import { MessageParticipantService } from 'src/modules/messaging/services/message-participant/message-participant.service';
import { MessageParticipantObjectMetadata } from 'src/modules/messaging/standard-objects/message-participant.object-metadata';
import { CalendarEventAttendeeService } from 'src/modules/calendar/services/calendar-event-attendee/calendar-event-attendee.service';
import { CalendarEventAttendeeRepository } from 'src/modules/calendar/repositories/calendar-event-attendee.repository';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantService } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service';
import { CalendarEventParticipantRepository } from 'src/modules/calendar/repositories/calendar-event-participant.repository';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { filterOutContactsFromCompanyOrWorkspace } from 'src/modules/connected-account/auto-companies-and-contacts-creation/utils/filter-out-contacts-from-company-or-workspace.util';
@Injectable()
@ -36,9 +36,9 @@ export class CreateCompanyAndContactService {
private readonly messageParticipantRepository: MessageParticipantRepository,
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
private readonly messageParticipantService: MessageParticipantService,
@InjectObjectMetadataRepository(CalendarEventAttendeeObjectMetadata)
private readonly calendarEventAttendeeRepository: CalendarEventAttendeeRepository,
private readonly calendarEventAttendeeService: CalendarEventAttendeeService,
@InjectObjectMetadataRepository(CalendarEventParticipantObjectMetadata)
private readonly calendarEventParticipantRepository: CalendarEventParticipantRepository,
private readonly calendarEventParticipantService: CalendarEventParticipantService,
) {}
async createCompaniesAndContacts(
@ -162,14 +162,14 @@ export class CreateCompanyAndContactService {
transactionManager,
);
const calendarEventAttendeesWithoutPersonIdAndWorkspaceMemberId =
await this.calendarEventAttendeeRepository.getWithoutPersonIdAndWorkspaceMemberId(
const calendarEventParticipantsWithoutPersonIdAndWorkspaceMemberId =
await this.calendarEventParticipantRepository.getWithoutPersonIdAndWorkspaceMemberId(
workspaceId,
transactionManager,
);
await this.calendarEventAttendeeService.updateCalendarEventAttendeesAfterContactCreation(
calendarEventAttendeesWithoutPersonIdAndWorkspaceMemberId,
await this.calendarEventParticipantService.updateCalendarEventParticipantsAfterContactCreation(
calendarEventParticipantsWithoutPersonIdAndWorkspaceMemberId,
workspaceId,
transactionManager,
);

View File

@ -16,7 +16,7 @@ import { RelationMetadata } from 'src/engine/workspace-manager/workspace-sync-me
import { ActivityTargetObjectMetadata } from 'src/modules/activity/standard-objects/activity-target.object-metadata';
import { AttachmentObjectMetadata } from 'src/modules/attachment/standard-objects/attachment.object-metadata';
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { CompanyObjectMetadata } from 'src/modules/company/standard-objects/company.object-metadata';
import { FavoriteObjectMetadata } from 'src/modules/favorite/standard-objects/favorite.object-metadata';
import { MessageParticipantObjectMetadata } from 'src/modules/messaging/standard-objects/message-participant.object-metadata';
@ -206,22 +206,22 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
messageParticipants: MessageParticipantObjectMetadata[];
@FieldMetadata({
standardId: personStandardFieldIds.calendarEventAttendees,
standardId: personStandardFieldIds.calendarEventParticipants,
type: FieldMetadataType.RELATION,
label: 'Calendar Event Attendees',
description: 'Calendar Event Attendees',
label: 'Calendar Event Participants',
description: 'Calendar Event Participants',
icon: 'IconCalendar',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
inverseSideTarget: () => CalendarEventAttendeeObjectMetadata,
inverseSideTarget: () => CalendarEventParticipantObjectMetadata,
onDelete: RelationOnDeleteAction.SET_NULL,
})
@Gate({
featureFlag: 'IS_CALENDAR_ENABLED',
})
@IsSystem()
calendarEventAttendees: CalendarEventAttendeeObjectMetadata[];
calendarEventParticipants: CalendarEventParticipantObjectMetadata[];
@FieldMetadata({
standardId: personStandardFieldIds.events,

View File

@ -15,7 +15,7 @@ import { ActivityObjectMetadata } from 'src/modules/activity/standard-objects/ac
import { AttachmentObjectMetadata } from 'src/modules/attachment/standard-objects/attachment.object-metadata';
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
import { BlocklistObjectMetadata } from 'src/modules/connected-account/standard-objects/blocklist.object-metadata';
import { CalendarEventAttendeeObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-attendee.object-metadata';
import { CalendarEventParticipantObjectMetadata } from 'src/modules/calendar/standard-objects/calendar-event-participant.object-metadata';
import { CommentObjectMetadata } from 'src/modules/activity/standard-objects/comment.object-metadata';
import { CompanyObjectMetadata } from 'src/modules/company/standard-objects/company.object-metadata';
import { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
@ -226,22 +226,22 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata {
blocklist: BlocklistObjectMetadata[];
@FieldMetadata({
standardId: workspaceMemberStandardFieldIds.calendarEventAttendees,
standardId: workspaceMemberStandardFieldIds.calendarEventParticipants,
type: FieldMetadataType.RELATION,
label: 'Calendar Event Attendees',
description: 'Calendar Event Attendees',
label: 'Calendar Event Participants',
description: 'Calendar Event Participants',
icon: 'IconCalendar',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
inverseSideTarget: () => CalendarEventAttendeeObjectMetadata,
inverseSideTarget: () => CalendarEventParticipantObjectMetadata,
inverseSideFieldKey: 'workspaceMember',
onDelete: RelationOnDeleteAction.SET_NULL,
})
@Gate({
featureFlag: 'IS_CALENDAR_ENABLED',
})
calendarEventAttendees: CalendarEventAttendeeObjectMetadata[];
calendarEventParticipants: CalendarEventParticipantObjectMetadata[];
@FieldMetadata({
standardId: workspaceMemberStandardFieldIds.events,