fix(AntiGateV2): also accept string taskId
All checks were successful
release-tag / release (push) Successful in 1m54s

This commit is contained in:
sati.ac 2023-07-14 04:05:08 +03:00
parent 5f60eb8752
commit 81193a05ef

@ -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
}