bugfix: escape destroyed objects on workers (#9719)
# This PR - Fixes #9358 @FelixMalfait please check this workaround --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { ObjectRecordBaseEvent } from 'src/engine/core-modules/event-emitter/types/object-record.base.event';
|
||||
import { ObjectRecordEvent } from 'src/engine/core-modules/event-emitter/types/object-record-event.event';
|
||||
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
|
||||
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
|
||||
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
||||
@ -20,7 +20,7 @@ export class CreateAuditLogFromInternalEvent {
|
||||
|
||||
@Process(CreateAuditLogFromInternalEvent.name)
|
||||
async handle(
|
||||
workspaceEventBatch: WorkspaceEventBatch<ObjectRecordBaseEvent>,
|
||||
workspaceEventBatch: WorkspaceEventBatch<ObjectRecordEvent>,
|
||||
): Promise<void> {
|
||||
for (const eventData of workspaceEventBatch.events) {
|
||||
let workspaceMemberId: string | null = null;
|
||||
@ -34,16 +34,14 @@ export class CreateAuditLogFromInternalEvent {
|
||||
workspaceMemberId = workspaceMember.id;
|
||||
}
|
||||
|
||||
if (eventData.properties.diff) {
|
||||
// we remove "before" and "after" property for a cleaner/slimmer event payload
|
||||
eventData.properties = {
|
||||
diff: eventData.properties.diff,
|
||||
};
|
||||
}
|
||||
|
||||
await this.auditLogRepository.insert(
|
||||
workspaceEventBatch.name,
|
||||
eventData.properties,
|
||||
'diff' in eventData.properties
|
||||
? {
|
||||
// we remove "before" and "after" property for a cleaner/slimmer event payload
|
||||
diff: eventData.properties.diff,
|
||||
}
|
||||
: eventData.properties,
|
||||
workspaceMemberId,
|
||||
workspaceEventBatch.name.split('.')[0],
|
||||
eventData.objectMetadata.id,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ObjectRecordBaseEvent } from 'src/engine/core-modules/event-emitter/types/object-record.base.event';
|
||||
import { ObjectRecordNonDestructiveEvent } from 'src/engine/core-modules/event-emitter/types/object-record-non-destructive-event';
|
||||
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
|
||||
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
|
||||
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
||||
@ -7,7 +7,6 @@ import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/types/wo
|
||||
import { TimelineActivityService } from 'src/modules/timeline/services/timeline-activity.service';
|
||||
import { WorkspaceMemberRepository } from 'src/modules/workspace-member/repositories/workspace-member.repository';
|
||||
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
|
||||
import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-objects/timeline-activity.workspace-entity';
|
||||
|
||||
@Processor(MessageQueue.entityEventsToDbQueue)
|
||||
export class UpsertTimelineActivityFromInternalEvent {
|
||||
@ -19,9 +18,7 @@ export class UpsertTimelineActivityFromInternalEvent {
|
||||
|
||||
@Process(UpsertTimelineActivityFromInternalEvent.name)
|
||||
async handle(
|
||||
workspaceEventBatch: WorkspaceEventBatch<
|
||||
ObjectRecordBaseEvent<TimelineActivityWorkspaceEntity>
|
||||
>,
|
||||
workspaceEventBatch: WorkspaceEventBatch<ObjectRecordNonDestructiveEvent>,
|
||||
): Promise<void> {
|
||||
for (const eventData of workspaceEventBatch.events) {
|
||||
if (eventData.userId) {
|
||||
@ -33,13 +30,6 @@ export class UpsertTimelineActivityFromInternalEvent {
|
||||
eventData.workspaceMemberId = workspaceMember.id;
|
||||
}
|
||||
|
||||
if (eventData.properties.diff) {
|
||||
// we remove "before" and "after" property for a cleaner/slimmer event payload
|
||||
eventData.properties = {
|
||||
diff: eventData.properties.diff,
|
||||
};
|
||||
}
|
||||
|
||||
// Temporary
|
||||
// We ignore every that is not a LinkedObject or a Business Object
|
||||
if (
|
||||
@ -51,7 +41,16 @@ export class UpsertTimelineActivityFromInternalEvent {
|
||||
}
|
||||
|
||||
await this.timelineActivityService.upsertEvent({
|
||||
event: eventData,
|
||||
event:
|
||||
// we remove "before" and "after" property for a cleaner/slimmer event payload
|
||||
'diff' in eventData.properties && eventData.properties.diff
|
||||
? {
|
||||
...eventData,
|
||||
properties: {
|
||||
diff: eventData.properties.diff,
|
||||
},
|
||||
}
|
||||
: eventData,
|
||||
eventName: workspaceEventBatch.name,
|
||||
workspaceId: workspaceEventBatch.workspaceId,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user