fixed translations being sent regardless of setting
This commit is contained in:
22
main.go
22
main.go
@@ -687,6 +687,7 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp := map[string][]*utils.ChatResponse{}
|
resp := map[string][]*utils.ChatResponse{}
|
||||||
|
if translate {
|
||||||
err = rdc.Get(context.Background(), fmt.Sprintf(utils.MatchChatCacheKey, matchId, lang.String()), &resp)
|
err = rdc.Get(context.Background(), fmt.Sprintf(utils.MatchChatCacheKey, matchId, lang.String()), &resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tStats, err := db.Messages.Query().Where(messages.HasMatchPlayerWith(matchplayer.HasMatchesWith(match.ID(matchId)))).WithMatchPlayer().All(context.Background())
|
tStats, err := db.Messages.Query().Where(messages.HasMatchPlayerWith(matchplayer.HasMatchesWith(match.ID(matchId)))).WithMatchPlayer().All(context.Background())
|
||||||
@@ -743,6 +744,27 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp[steamid] = append(resp[steamid], &utils.ChatResponse{
|
||||||
|
Message: stat.Message,
|
||||||
|
AllChat: stat.AllChat,
|
||||||
|
Tick: stat.Tick,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = utils.SendJSON(resp, w)
|
err = utils.SendJSON(resp, w)
|
||||||
|
Reference in New Issue
Block a user