From bcbc261e3bb3e87b61fc64a33103f646f229bdf1 Mon Sep 17 00:00:00 2001 From: ssmucny Date: Mon, 24 Apr 2023 22:35:32 -0400 Subject: [PATCH] Bug fix in extractEventFromNote with minimum Note --- .../core/activitypub/models/ApEventService.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/core/activitypub/models/ApEventService.ts b/packages/backend/src/core/activitypub/models/ApEventService.ts index 3a9117a77c..3382258d90 100644 --- a/packages/backend/src/core/activitypub/models/ApEventService.ts +++ b/packages/backend/src/core/activitypub/models/ApEventService.ts @@ -41,15 +41,19 @@ export class ApEventService { throw new Error('invalid type'); } - const title = note.name!; - const start = note.startTime!; - const end = note.endTime ?? null; + if (note.name && note.startTime) { + const title = note.name; + const start = note.startTime; + const end = note.endTime ?? null; - return { - title, - start, - end, - metadata: {}, - }; + return { + title, + start, + end, + metadata: {}, + }; + } else { + throw new Error('Invalid event properties') + } } }