Skip to content

Commit a5c9521

Browse files
committed
🐛 fix(duplicate-event): fix event duplication - backend
1 parent 8d42b48 commit a5c9521

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/backend/src/event/controllers/event.controller.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ class EventController {
2222
private async processEvents(_events: CompassEvent[]) {
2323
const events = _events.map((e) => ({
2424
...e,
25-
payload: CompassCoreEventSchema.parse(e.payload),
25+
payload: CompassCoreEventSchema.parse({
26+
...e.payload,
27+
_id:
28+
e.payload._id?.replace(`${ID_OPTIMISTIC_PREFIX}-`, "") ??
29+
new ObjectId().toString(),
30+
}),
2631
})) as CompassEvent[];
2732

2833
await CompassSyncProcessor.processEvents(events);
@@ -39,15 +44,11 @@ class EventController {
3944
// Handle both single object and array cases
4045
const events = Array.isArray(body) ? body : [body];
4146

47+
console.log(events);
48+
4249
await this.processEvents(
4350
events.map((e) => ({
44-
payload: {
45-
...e,
46-
_id:
47-
e._id?.replace(`${ID_OPTIMISTIC_PREFIX}`, "") ??
48-
new ObjectId().toString(),
49-
user,
50-
},
51+
payload: { ...e, user },
5152
status: CompassEventStatus.CONFIRMED,
5253
applyTo: RecurringEventUpdateScope.THIS_EVENT,
5354
})) as CompassEvent[],

0 commit comments

Comments
 (0)