From 4fdbf1c7127b450d61b8678222095820c1896e82 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Mon, 26 Jun 2023 07:47:56 -0400 Subject: [PATCH] fix: back from the future --- packages/backend/src/services/note/create.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index ba6859249d..defd9742e2 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -196,7 +196,13 @@ export default async ( data.channel = await Channels.findOneBy({ id: data.reply.channelId }); } - if (data.createdAt == null) data.createdAt = new Date(); + const now = new Date(); + if ( + !data.createdAt || + isNaN(data.createdAt.getTime()) || + data.createdAt > now + ) + data.createdAt = now; if (data.visibility == null) data.visibility = "public"; if (data.localOnly == null) data.localOnly = false; if (data.channel != null) data.visibility = "public";