From 81193a05ef9dc692a5bc7fae8e2a93dda00b14a0 Mon Sep 17 00:00:00 2001 From: "sati.ac" Date: Fri, 14 Jul 2023 04:05:08 +0300 Subject: [PATCH] fix(AntiGateV2): also accept string taskId --- api/AntiGateV2.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/api/AntiGateV2.go b/api/AntiGateV2.go index 88a9813..fcac225 100644 --- a/api/AntiGateV2.go +++ b/api/AntiGateV2.go @@ -5,6 +5,7 @@ import ( "io" "net/http" "reflect" + "strconv" "strings" "git.sati.ac/sati.ac/sati-go" @@ -83,9 +84,23 @@ var ( ) func (a *antigateV2Api) getTaskResult(request struct { - TaskId uint32 `json:"taskId"` + TaskId any `json:"taskId"` }) any { - task := a.ctx.Registry.Get(request.TaskId) + var taskId uint32 + switch id := request.TaskId.(type) { + case float64: + taskId = uint32(id) + case string: + parsed, err := strconv.ParseUint(id, 10, 32) + if err != nil { + return errorBadRequest + } + taskId = uint32(parsed) + default: + return errorBadRequest + } + + task := a.ctx.Registry.Get(taskId) if task == nil { return errorNoSuchCaptchaId }