POC timeline activity (#5697)

TODO: 
- remove WorkspaceIsNotAuditLogged decorators on activity/activityTarget
to log task/note creations
- handle attachments
-  fix css and remove unnecessary styled components or duplicates
This commit is contained in:
Weiko
2024-06-11 18:53:28 +02:00
committed by GitHub
parent 64b8e4ec4d
commit be96c68416
60 changed files with 2134 additions and 443 deletions

View File

@ -2,11 +2,13 @@ import { Injectable } from '@nestjs/common';
import { MessageQueueJob } from 'src/engine/integrations/message-queue/interfaces/message-queue-job.interface';
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
import { CreateCompanyAndContactService } from 'src/modules/connected-account/auto-companies-and-contacts-creation/services/create-company-and-contact.service';
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
export type CreateCompanyAndContactJobData = {
workspaceId: string;
connectedAccountHandle: string;
connectedAccount: ObjectRecord<ConnectedAccountWorkspaceEntity>;
contactsToCreate: {
displayName: string;
handle: string;
@ -22,10 +24,10 @@ export class CreateCompanyAndContactJob
) {}
async handle(data: CreateCompanyAndContactJobData): Promise<void> {
const { workspaceId, connectedAccountHandle, contactsToCreate } = data;
const { workspaceId, connectedAccount, contactsToCreate } = data;
await this.createCompanyAndContactService.createCompaniesAndContactsAndUpdateParticipants(
connectedAccountHandle,
connectedAccount,
contactsToCreate.map((contact) => ({
handle: contact.handle,
displayName: contact.displayName,

View File

@ -1,4 +1,5 @@
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { EntityManager } from 'typeorm';
import compact from 'lodash.compact';
@ -19,6 +20,9 @@ import { CalendarEventParticipantService } from 'src/modules/calendar/services/c
import { filterOutContactsFromCompanyOrWorkspace } from 'src/modules/connected-account/auto-companies-and-contacts-creation/utils/filter-out-contacts-from-company-or-workspace.util';
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
import { MessagingMessageParticipantService } from 'src/modules/messaging/common/services/messaging-message-participant.service';
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
import { MessageParticipantWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-participant.workspace-entity';
import { CalendarEventParticipantWorkspaceEntity } from 'src/modules/calendar/standard-objects/calendar-event-participant.workspace-entity';
@Injectable()
export class CreateCompanyAndContactService {
@ -32,6 +36,7 @@ export class CreateCompanyAndContactService {
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
private readonly messageParticipantService: MessagingMessageParticipantService,
private readonly calendarEventParticipantService: CalendarEventParticipantService,
private readonly eventEmitter: EventEmitter2,
) {}
async createCompaniesAndPeople(
@ -125,7 +130,7 @@ export class CreateCompanyAndContactService {
}
async createCompaniesAndContactsAndUpdateParticipants(
connectedAccountHandle: string,
connectedAccount: ObjectRecord<ConnectedAccountWorkspaceEntity>,
contactsToCreate: Contacts,
workspaceId: string,
) {
@ -134,27 +139,46 @@ export class CreateCompanyAndContactService {
workspaceId,
);
let updatedMessageParticipants: ObjectRecord<MessageParticipantWorkspaceEntity>[] =
[];
let updatedCalendarEventParticipants: ObjectRecord<CalendarEventParticipantWorkspaceEntity>[] =
[];
await workspaceDataSource?.transaction(
async (transactionManager: EntityManager) => {
const createdPeople = await this.createCompaniesAndPeople(
connectedAccountHandle,
connectedAccount.handle,
contactsToCreate,
workspaceId,
transactionManager,
);
await this.messageParticipantService.updateMessageParticipantsAfterPeopleCreation(
createdPeople,
workspaceId,
transactionManager,
);
updatedMessageParticipants =
await this.messageParticipantService.updateMessageParticipantsAfterPeopleCreation(
createdPeople,
workspaceId,
transactionManager,
);
await this.calendarEventParticipantService.updateCalendarEventParticipantsAfterPeopleCreation(
createdPeople,
workspaceId,
transactionManager,
);
updatedCalendarEventParticipants =
await this.calendarEventParticipantService.updateCalendarEventParticipantsAfterPeopleCreation(
createdPeople,
workspaceId,
transactionManager,
);
},
);
this.eventEmitter.emit(`messageParticipant.matched`, {
workspaceId,
userId: connectedAccount.accountOwnerId,
messageParticipants: updatedMessageParticipants,
});
this.eventEmitter.emit(`calendarEventParticipant.matched`, {
workspaceId,
userId: connectedAccount.accountOwnerId,
calendarEventParticipants: updatedCalendarEventParticipants,
});
}
}