From aad066837c1d79ced9c8f38bf5880516ceb8326b Mon Sep 17 00:00:00 2001 From: maru Date: Thu, 18 Apr 2024 02:00:49 -0400 Subject: [PATCH] Fix bug with /savedata/clear endpoint --- api/endpoints.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/endpoints.go b/api/endpoints.go index ce17889..58b4e13 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -191,8 +191,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { case "/savedata/delete": err = savedata.Delete(uuid, datatype, slot) case "/savedata/clear": + s, ok := save.(defs.SessionSaveData) + if !ok { + httpError(w, r, fmt.Errorf("save data is not type SessionSaveData"), http.StatusBadRequest) + return + } + // doesn't return a save, but it works - save, err = savedata.Clear(uuid, slot, daily.Seed(), save.(defs.SessionSaveData)) + save, err = savedata.Clear(uuid, slot, daily.Seed(), s) } if err != nil { httpError(w, r, err, http.StatusInternalServerError)