summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-02-21 11:56:56 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-02-21 12:01:49 +1100
commiteee98516dd09516f1c1cf891526339420807d50c (patch)
tree8d60f6717eac0416bcb73421ca71c31bdc1fff68 /src/api
parentClose #954 (diff)
downloadserver-eee98516dd09516f1c1cf891526339420807d50c.tar.xz
Fix gateway encoding Date objects as {} when using erlpack. Fixes NaN/NaN/NaN timestamps in desktop client
Diffstat (limited to 'src/api')
-rw-r--r--src/api/Server.ts20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/api/Server.ts b/src/api/Server.ts
index 78870669..7eb4e6f1 100644
--- a/src/api/Server.ts
+++ b/src/api/Server.ts
@@ -23,6 +23,7 @@ import {
 	Config,
 	initDatabase,
 	initEvent,
+	JSONReplacer,
 	Sentry,
 	WebAuthn,
 } from "@fosscord/util";
@@ -84,24 +85,7 @@ export class FosscordServer extends Server {
 			);
 		}
 
-		// Discord.com sends ISO strings with +00:00 extension, not Z
-		// This causes issues with Python bot libs
-		this.app.set(
-			"json replacer",
-			function (
-				this: { [key: string]: unknown },
-				key: string,
-				value: unknown,
-			) {
-				if (this[key] instanceof Date) {
-					return (this[key] as Date)
-						.toISOString()
-						.replace("Z", "+00:00");
-				}
-
-				return value;
-			},
-		);
+		this.app.set("json replacer", JSONReplacer);
 
 		this.app.use(CORS);
 		this.app.use(BodyParser({ inflate: true, limit: "10mb" }));