11package users
22
33import (
4- "context"
54 "net/http"
6- "strings"
7- "time"
85
96 "reverse-watch/domain/dto"
107 "reverse-watch/domain/models"
@@ -22,25 +19,12 @@ type fetchUserStatusResponse struct {
2219 LastReversalTimestamp * uint64 `json:"last_reversal_timestamp,omitempty"`
2320}
2421
25- func fetchUserStatus (steamWebAPIKey string ) http.HandlerFunc {
22+ func fetchUserStatus () http.HandlerFunc {
2623 return func (w http.ResponseWriter , r * http.Request ) {
2724 factory := r .Context ().Value (middleware .FactoryContextKey ).(repository.Factory )
2825
2926 steamIdStr := chi .URLParam (r , "steamId" )
30- client := & http.Client {Timeout : 15 * time .Second }
31- ctx , cancel := context .WithTimeout (r .Context (), 15 * time .Second )
32- defer cancel ()
33-
34- var steamId * models.SteamID
35- var err error
36- if strings .TrimSpace (steamWebAPIKey ) != "" {
37- steamId , err = models .ParseSteamUserInputWithOpts (ctx , client , steamIdStr , & models.SteamUserInputOpts {
38- UseWebAPIForVanity : true ,
39- SteamWebAPIKey : steamWebAPIKey ,
40- })
41- } else {
42- steamId , err = models .ParseSteamUserInput (ctx , client , steamIdStr )
43- }
27+ steamId , err := models .ToSteamID (steamIdStr )
4428 if err != nil {
4529 render .Errorf (w , r , errors .BadRequest , "invalid steam id" )
4630 return
0 commit comments