From aed26ffcd30c5d4514bca9d5cb4d7bcfabe0403c Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Sun, 3 Nov 2024 23:14:47 +0000 Subject: [PATCH 1/2] Fix JSON parsing exception caused by double-encoding metrics data (!422) Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/422 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- project/src/callbacks/MatchCallbacks.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/src/callbacks/MatchCallbacks.ts b/project/src/callbacks/MatchCallbacks.ts index 57ebd3f8..3f538746 100644 --- a/project/src/callbacks/MatchCallbacks.ts +++ b/project/src/callbacks/MatchCallbacks.ts @@ -1,5 +1,6 @@ import { MatchController } from "@spt/controllers/MatchController"; import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData"; +import { IMetrics } from "@spt/models/eft/common/tables/IMatch"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; import { INullResponseData } from "@spt/models/eft/httpResponse/INullResponseData"; import { IEndLocalRaidRequestData } from "@spt/models/eft/match/IEndLocalRaidRequestData"; @@ -137,8 +138,8 @@ export class MatchCallbacks { } /** Handle client/getMetricsConfig */ - public getMetrics(url: string, info: any, sessionID: string): IGetBodyResponseData { - return this.httpResponse.getBody(this.jsonUtil.serialize(this.databaseService.getMatch().metrics)); + public getMetrics(url: string, info: any, sessionID: string): IGetBodyResponseData { + return this.httpResponse.getBody(this.databaseService.getMatch().metrics); } /** From 78a3fcaca0d75f2f6533e26bbcaccc752ef6a554 Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Sun, 3 Nov 2024 23:26:03 +0000 Subject: [PATCH 2/2] Properly fix metrics call, oops (!423) Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/423 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- project/src/routers/static/MatchStaticRouter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/src/routers/static/MatchStaticRouter.ts b/project/src/routers/static/MatchStaticRouter.ts index e0811b7c..c36ea0d8 100644 --- a/project/src/routers/static/MatchStaticRouter.ts +++ b/project/src/routers/static/MatchStaticRouter.ts @@ -1,6 +1,7 @@ import { MatchCallbacks } from "@spt/callbacks/MatchCallbacks"; import { RouteAction, StaticRouter } from "@spt/di/Router"; import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData"; +import { IMetrics } from "@spt/models/eft/common/tables/IMatch"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; import { INullResponseData } from "@spt/models/eft/httpResponse/INullResponseData"; import { IGroupCharacter } from "@spt/models/eft/match/IGroupCharacter"; @@ -228,7 +229,7 @@ export class MatchStaticRouter extends StaticRouter { info: any, sessionID: string, output: string, - ): Promise> => { + ): Promise> => { return this.matchCallbacks.getMetrics(url, info, sessionID); }, ),