updated deps, added golangci linter

This commit is contained in:
2022-11-20 18:11:52 +01:00
parent d10a134a34
commit 5b938f4d06
8 changed files with 231 additions and 154 deletions

28
main.go
View File

@@ -138,7 +138,7 @@ func housekeeping() {
}
for _, m := range tMatches {
demo := &csgo.Demo{MatchId: m.ID, ShareCode: m.ShareCode}
demo := &csgo.Demo{MatchID: m.ID, ShareCode: m.ShareCode}
if demoLoader.IsLoading(demo) {
log.Infof("[HK] Skipping %s: parsing in progress", m.ShareCode)
continue
@@ -216,24 +216,25 @@ func housekeeping() {
for _, tPlayer := range tPlayerNeedShareCodeUpdate {
shareCodes, err := utils.GetNewShareCodesForPlayer(tPlayer, conf.Steam.APIKey, rL)
if err != nil {
if errors.Is(err, utils.AuthcodeUnauthorizedError) {
switch {
case errors.Is(err, utils.AuthcodeUnauthorizedError):
log.Infof("[HK] authCode for player %d is no longer valid", tPlayer.ID)
err = tPlayer.Update().ClearAuthCode().ClearSharecodeUpdated().Exec(context.Background())
if err != nil {
log.Errorf("[HK] Unable to clear authcode for player %d: %v", tPlayer.ID, err)
}
continue
} else if errors.Is(err, utils.SharecodeNoMatchError) {
case errors.Is(err, utils.SharecodeNoMatchError):
log.Warningf("[HK] last shareCode for player %d does not match player", tPlayer.ID)
continue
} else if errors.Is(err, utils.NoMatchError) {
case errors.Is(err, utils.NoMatchError):
log.Infof("[HK] tracked player %d with no matches found, untracked", tPlayer.ID)
err = tPlayer.Update().ClearAuthCode().ClearSharecodeUpdated().Exec(context.Background())
if err != nil {
log.Errorf("[HK] Unable to clear authcode for player %d: %v", tPlayer.ID, err)
}
continue
} else {
default:
log.Errorf("[HK] Error while requesting sharecodes for %d: %v", tPlayer.ID, err)
continue
}
@@ -533,15 +534,16 @@ func postPlayerTrack(c *gin.Context) {
_, err = utils.IsAuthCodeValid(tPlayer, conf.Steam.APIKey, shareCode, authCode, rL)
if err != nil {
if errors.Is(err, utils.AuthcodeUnauthorizedError) {
switch {
case errors.Is(err, utils.AuthcodeUnauthorizedError):
log.Infof("[PPT] authCode provided for player %s is invalid: %v", id, err)
c.Status(http.StatusUnauthorized)
return
} else if errors.Is(err, utils.SharecodeNoMatchError) {
case errors.Is(err, utils.SharecodeNoMatchError):
log.Infof("[PPT] shareCode provided for player %s (%s) is invalid: %v", id, shareCode, err)
c.Status(http.StatusPreconditionFailed)
return
} else {
default:
log.Infof("[PPT] problem with request: %v", err)
c.Status(http.StatusServiceUnavailable)
return
@@ -1093,7 +1095,7 @@ func main() {
migrate.WithDropIndex(true),
migrate.WithDropColumn(true),
); err != nil {
log.Fatalf("Automigrate failed: %v", err)
log.Panicf("Automigrate failed: %v", err)
}
rdb = redis.NewClient(&redis.Options{
@@ -1116,16 +1118,16 @@ func main() {
AuthCode: conf.Steam.AuthCode,
Sentry: conf.Steam.Sentry,
LoginKey: conf.Steam.LoginKey,
Db: db,
DB: db,
Worker: conf.Parser.Worker,
ApiKey: conf.Steam.APIKey,
APIKey: conf.Steam.APIKey,
RateLimit: rL,
Cache: rdc,
SprayTimeout: conf.Csgowtfd.SprayTimeout,
RetryTimeout: conf.Steam.MaxRetryWait,
})
if err != nil {
log.Fatalf("Error setting up DemoLoader: %v", err)
log.Panicf("Error setting up DemoLoader: %v", err)
}
// start housekeeper
@@ -1174,7 +1176,7 @@ func main() {
sL, err := net.Listen("unix", l.Socket)
log.Infof("Listening on %s", l.Socket)
if err != nil {
log.Fatalf("Failure listing on socket %s: %v", l.Socket, err)
log.Panicf("Failure listing on socket %s: %v", l.Socket, err)
}
sockets = append(sockets, sL)
go func() {