diff --git a/main.go b/main.go index 572f6ea..0f11077 100644 --- a/main.go +++ b/main.go @@ -744,26 +744,26 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) return } - } else { - tStats, err := db.Messages.Query().Where(messages.HasMatchPlayerWith(matchplayer.HasMatchesWith(match.ID(matchId)))).WithMatchPlayer().All(context.Background()) - if err != nil { - log.Infof("[GMC] match %d not found: %+v", matchId, err) - w.WriteHeader(http.StatusNotFound) - return + } + } else { + tStats, err := db.Messages.Query().Where(messages.HasMatchPlayerWith(matchplayer.HasMatchesWith(match.ID(matchId)))).WithMatchPlayer().All(context.Background()) + if err != nil { + log.Infof("[GMC] match %d not found: %+v", matchId, err) + w.WriteHeader(http.StatusNotFound) + return + } + + for _, stat := range tStats { + steamid := strconv.FormatUint(stat.Edges.MatchPlayer.PlayerStats, 10) + if _, ok := resp[steamid]; !ok { + resp[steamid] = make([]*utils.ChatResponse, 0) } - for _, stat := range tStats { - steamid := strconv.FormatUint(stat.Edges.MatchPlayer.PlayerStats, 10) - if _, ok := resp[steamid]; !ok { - resp[steamid] = make([]*utils.ChatResponse, 0) - } - - resp[steamid] = append(resp[steamid], &utils.ChatResponse{ - Message: stat.Message, - AllChat: stat.AllChat, - Tick: stat.Tick, - }) - } + resp[steamid] = append(resp[steamid], &utils.ChatResponse{ + Message: stat.Message, + AllChat: stat.AllChat, + Tick: stat.Tick, + }) } }