mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-04-03 03:27:13 +08:00
chore: Update savedata API to handle session out of date errors
This commit is contained in:
parent
4e4ac38e20
commit
fee5d7194c
@ -197,6 +197,7 @@ func handleSession(w http.ResponseWriter, r *http.Request) {
|
|||||||
httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest)
|
httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
existingSave, err := savedata.GetSession(uuid, slot)
|
existingSave, err := savedata.GetSession(uuid, slot)
|
||||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||||
httpError(w, r, fmt.Errorf("failed to retrieve session save data: %s", err), http.StatusInternalServerError)
|
httpError(w, r, fmt.Errorf("failed to retrieve session save data: %s", err), http.StatusInternalServerError)
|
||||||
@ -207,6 +208,7 @@ func handleSession(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = savedata.UpdateSession(uuid, slot, session)
|
err = savedata.UpdateSession(uuid, slot, session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpError(w, r, fmt.Errorf("failed to put session data: %s", err), http.StatusInternalServerError)
|
httpError(w, r, fmt.Errorf("failed to put session data: %s", err), http.StatusInternalServerError)
|
||||||
@ -325,6 +327,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
|||||||
httpError(w, r, fmt.Errorf("no playtime found"), http.StatusBadRequest)
|
httpError(w, r, fmt.Errorf("no playtime found"), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if float64(existingPlaytime) > playtime {
|
if float64(existingPlaytime) > playtime {
|
||||||
httpError(w, r, fmt.Errorf("session out of date: existing playtime is greater"), http.StatusBadRequest)
|
httpError(w, r, fmt.Errorf("session out of date: existing playtime is greater"), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
@ -426,6 +429,7 @@ func handleSystem(w http.ResponseWriter, r *http.Request) {
|
|||||||
httpError(w, r, fmt.Errorf("no playtime found"), http.StatusBadRequest)
|
httpError(w, r, fmt.Errorf("no playtime found"), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if float64(existingPlaytime) > playtime {
|
if float64(existingPlaytime) > playtime {
|
||||||
httpError(w, r, fmt.Errorf("session out of date: existing playtime is greater"), http.StatusBadRequest)
|
httpError(w, r, fmt.Errorf("session out of date: existing playtime is greater"), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user