8643 fix sentry error (#8644)
- fixes missing data in event payload when adding a new workspaceMember - add strong typing to database event emitters
This commit is contained in:
@ -6,7 +6,7 @@ import { objectRecordChangedProperties as objectRecordUpdateEventChangedProperti
|
||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
||||
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/workspace-event.type';
|
||||
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/types/workspace-event.type';
|
||||
import {
|
||||
CalendarEventParticipantMatchParticipantJob,
|
||||
CalendarEventParticipantMatchParticipantJobData,
|
||||
@ -16,7 +16,7 @@ import {
|
||||
CalendarEventParticipantUnmatchParticipantJobData,
|
||||
} from 'src/modules/calendar/calendar-event-participant-manager/jobs/calendar-event-participant-unmatch-participant.job';
|
||||
import { PersonWorkspaceEntity } from 'src/modules/person/standard-objects/person.workspace-entity';
|
||||
import { OnDatabaseEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-database-event.decorator';
|
||||
import { OnDatabaseBatchEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-database-batch-event.decorator';
|
||||
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
||||
|
||||
@Injectable()
|
||||
@ -26,7 +26,7 @@ export class CalendarEventParticipantPersonListener {
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
) {}
|
||||
|
||||
@OnDatabaseEvent('person', DatabaseEventAction.CREATED)
|
||||
@OnDatabaseBatchEvent('person', DatabaseEventAction.CREATED)
|
||||
async handleCreatedEvent(
|
||||
payload: WorkspaceEventBatch<
|
||||
ObjectRecordCreateEvent<PersonWorkspaceEntity>
|
||||
@ -49,7 +49,7 @@ export class CalendarEventParticipantPersonListener {
|
||||
}
|
||||
}
|
||||
|
||||
@OnDatabaseEvent('person', DatabaseEventAction.UPDATED)
|
||||
@OnDatabaseBatchEvent('person', DatabaseEventAction.UPDATED)
|
||||
async handleUpdatedEvent(
|
||||
payload: WorkspaceEventBatch<
|
||||
ObjectRecordUpdateEvent<PersonWorkspaceEntity>
|
||||
|
||||
@ -6,7 +6,7 @@ import { objectRecordChangedProperties as objectRecordUpdateEventChangedProperti
|
||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
||||
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/workspace-event.type';
|
||||
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/types/workspace-event.type';
|
||||
import {
|
||||
CalendarEventParticipantMatchParticipantJob,
|
||||
CalendarEventParticipantMatchParticipantJobData,
|
||||
@ -16,7 +16,7 @@ import {
|
||||
CalendarEventParticipantUnmatchParticipantJobData,
|
||||
} from 'src/modules/calendar/calendar-event-participant-manager/jobs/calendar-event-participant-unmatch-participant.job';
|
||||
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
|
||||
import { OnDatabaseEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-database-event.decorator';
|
||||
import { OnDatabaseBatchEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-database-batch-event.decorator';
|
||||
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
||||
|
||||
@Injectable()
|
||||
@ -26,7 +26,7 @@ export class CalendarEventParticipantWorkspaceMemberListener {
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
) {}
|
||||
|
||||
@OnDatabaseEvent('workspaceMember', DatabaseEventAction.CREATED)
|
||||
@OnDatabaseBatchEvent('workspaceMember', DatabaseEventAction.CREATED)
|
||||
async handleCreatedEvent(
|
||||
payload: WorkspaceEventBatch<
|
||||
ObjectRecordCreateEvent<WorkspaceMemberWorkspaceEntity>
|
||||
@ -48,7 +48,7 @@ export class CalendarEventParticipantWorkspaceMemberListener {
|
||||
}
|
||||
}
|
||||
|
||||
@OnDatabaseEvent('workspaceMember', DatabaseEventAction.UPDATED)
|
||||
@OnDatabaseBatchEvent('workspaceMember', DatabaseEventAction.UPDATED)
|
||||
async handleUpdatedEvent(
|
||||
payload: WorkspaceEventBatch<
|
||||
ObjectRecordUpdateEvent<WorkspaceMemberWorkspaceEntity>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
@ -7,10 +6,11 @@ import { Repository } from 'typeorm';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/workspace-event.type';
|
||||
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/types/workspace-event.type';
|
||||
import { CalendarEventParticipantWorkspaceEntity } from 'src/modules/calendar/common/standard-objects/calendar-event-participant.workspace-entity';
|
||||
import { TimelineActivityRepository } from 'src/modules/timeline/repositiories/timeline-activity.repository';
|
||||
import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-objects/timeline-activity.workspace-entity';
|
||||
import { OnCustomBatchEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-custom-batch-event.decorator';
|
||||
|
||||
@Injectable()
|
||||
export class CalendarEventParticipantListener {
|
||||
@ -22,17 +22,17 @@ export class CalendarEventParticipantListener {
|
||||
private readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
|
||||
) {}
|
||||
|
||||
@OnEvent('calendarEventParticipant.matched')
|
||||
@OnCustomBatchEvent('calendarEventParticipant_matched')
|
||||
public async handleCalendarEventParticipantMatchedEvent(
|
||||
payload: WorkspaceEventBatch<{
|
||||
batchEvent: WorkspaceEventBatch<{
|
||||
workspaceMemberId: string;
|
||||
participants: CalendarEventParticipantWorkspaceEntity[];
|
||||
}>,
|
||||
): Promise<void> {
|
||||
const workspaceId = payload.workspaceId;
|
||||
const workspaceId = batchEvent.workspaceId;
|
||||
|
||||
// TODO: Refactor to insertTimelineActivitiesForObject once
|
||||
for (const eventPayload of payload.events) {
|
||||
for (const eventPayload of batchEvent.events) {
|
||||
const calendarEventParticipants = eventPayload.participants;
|
||||
const workspaceMemberId = eventPayload.workspaceMemberId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user