From 34043227408f353aa0554556c96fa3636f00b669 Mon Sep 17 00:00:00 2001 From: ihsangan Date: Tue, 29 Oct 2024 18:55:31 +0800 Subject: [PATCH] fix error in gi & hsr: always return success 200 --- src/router/gi.ts | 24 ++++++++++++++++-------- src/router/hsr.ts | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 16 deletions(-) mode change 100755 => 100644 src/router/gi.ts mode change 100755 => 100644 src/router/hsr.ts diff --git a/src/router/gi.ts b/src/router/gi.ts old mode 100755 new mode 100644 index 35bffef..ca5b64a --- a/src/router/gi.ts +++ b/src/router/gi.ts @@ -24,7 +24,7 @@ export default async function gi(id: number): Promise { default: return { success: false, - message: 'Bad request' + message: 'Not found' }; } const body = `voucherPricePoint.id=116054&voucherPricePoint.price=16500&voucherPricePoint.variablePrice=0&user.userId=${id}&user.zoneId=${sv}&voucherTypeName=GENSHIN_IMPACT&shopLang=id_ID`; @@ -34,11 +34,19 @@ export default async function gi(id: number): Promise { body }); const data = await response.json(); - return { - success: true, - game: 'Genshin Impact', - id, - server: sn, - name: data.confirmationFields.username - }; + if (data.confirmationFields.username) { + return { + success: true, + game: 'Genshin Impact', + id, + server: sn, + name: data.confirmationFields.username + }; + } + else { + return { + success: false, + message: 'Not found' + } + } } \ No newline at end of file diff --git a/src/router/hsr.ts b/src/router/hsr.ts old mode 100755 new mode 100644 index 766fc8f..b09d4bb --- a/src/router/hsr.ts +++ b/src/router/hsr.ts @@ -24,7 +24,7 @@ export default async function hsr(id: number): Promise { default: return { success: false, - message: 'Bad request', + message: 'Not found', }; } const body = `voucherPricePoint.id=855316&voucherPricePoint.price=16000&voucherPricePoint.variablePrice=0&user.userId=${id}&user.zoneId=${sv}&voucherTypeName=HONKAI_STAR_RAIL&shopLang=id_ID`; @@ -34,11 +34,19 @@ export default async function hsr(id: number): Promise { body }); const data = await response.json(); - return { - success: true, - game: 'Honkai: Star Rail', - id, - server: sn, - name: data.confirmationFields.username - }; + if (data.confirmationFields.username) { + return { + success: true, + game: 'Honkai: Star Rail', + id, + server: sn, + name: data.confirmationFields.username + } + } + else { + return { + success: false, + message: 'Not found' + } + } } \ No newline at end of file