try parsing match first
This commit is contained in:
15
main.go
15
main.go
@@ -511,6 +511,15 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if shareCode != "" && utils.ShareCodeRegEx.MatchString(shareCode) {
|
||||||
|
err := demoLoader.LoadDemo(&csgo.Demo{ShareCode: shareCode})
|
||||||
|
if err != nil {
|
||||||
|
log.Warningf("[PPT] unable to queue match: %v", err)
|
||||||
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err = utils.IsAuthCodeValid(tPlayer, conf.Steam.APIKey, shareCode, authCode, rL)
|
_, err = utils.IsAuthCodeValid(tPlayer, conf.Steam.APIKey, shareCode, authCode, rL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch e := err.(type) {
|
switch e := err.(type) {
|
||||||
@@ -522,12 +531,8 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Infof("[PPT] shareCode provided for player %s is invalid: %v", id, e)
|
log.Infof("[PPT] shareCode provided for player %s is invalid: %v", id, e)
|
||||||
w.WriteHeader(http.StatusPreconditionFailed)
|
w.WriteHeader(http.StatusPreconditionFailed)
|
||||||
return
|
return
|
||||||
case *ent.NotFoundError:
|
|
||||||
log.Infof("[PPT] match not found for player %+v: %+v, %+v", id, authCode, shareCode)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
default:
|
default:
|
||||||
log.Infof("[PPT] Temporary Steam-API problem: %v", e)
|
log.Infof("[PPT] problem with request: %v", e)
|
||||||
w.WriteHeader(http.StatusServiceUnavailable)
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -476,7 +476,7 @@ func IsAuthCodeValid(player *ent.Player, apiKey string, shareCode string, authCo
|
|||||||
if shareCode == "" {
|
if shareCode == "" {
|
||||||
tMatch, err = player.QueryMatches().Order(ent.Asc(match.FieldDate)).First(context.Background())
|
tMatch, err = player.QueryMatches().Order(ent.Asc(match.FieldDate)).First(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, SharecodeNoMatchError{errors.New("sharecode not provided")}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := getNextShareCode(tMatch.ShareCode, apiKey, authCode, player.ID, rl)
|
_, err := getNextShareCode(tMatch.ShareCode, apiKey, authCode, player.ID, rl)
|
||||||
|
Reference in New Issue
Block a user