From 1606163ad759ab8ad4bd5c377dc34c428bcac37a Mon Sep 17 00:00:00 2001 From: Namekuji Date: Tue, 5 Sep 2023 19:44:37 -0400 Subject: [PATCH] fix: file createdAt can be string --- packages/backend/src/db/scylla.ts | 2 +- packages/backend/src/models/repositories/note.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/db/scylla.ts b/packages/backend/src/db/scylla.ts index 1f38cee5f3..16bc68b954 100644 --- a/packages/backend/src/db/scylla.ts +++ b/packages/backend/src/db/scylla.ts @@ -140,7 +140,7 @@ export function parseScyllaNotification(row: types.Row): ScyllaNotification { export interface ScyllaDriveFile { id: string; type: string; - createdAt: Date; + createdAt: Date | string; name: string; comment: string | null; blurhash: string | null; diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 7744128507..a65df2b582 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -327,7 +327,10 @@ export const NoteRepository = db.getRepository(Note).extend({ ? (note as ScyllaNote).files.map((file) => ({ ...file, thumbnailUrl: getScyllaDrivePublicUrl(file, true), - createdAt: file.createdAt.toISOString(), + createdAt: (typeof file.createdAt === "string" + ? new Date(file.createdAt) + : file.createdAt + ).toISOString(), properties: { width: file.width ?? undefined, height: file.height ?? undefined,