diff --git a/fortnite/external.go b/fortnite/external.go index 0388a96..10d145d 100644 --- a/fortnite/external.go +++ b/fortnite/external.go @@ -18,13 +18,13 @@ var ( type ExternalDataClient struct { h *http.Client - FortniteSets map[string]*FortniteSet - FortniteItems map[string]*FortniteItem - FortniteItemsWithDisplayAssets map[string]*FortniteItem - FortniteItemsWithFeaturedImage []*FortniteItem - TypedFortniteItems map[string][]*FortniteItem - TypedFortniteItemsWithDisplayAssets map[string][]*FortniteItem - SnowVariantTokens map[string]SnowCosmeticVariantToken + FortniteSets map[string]*FortniteSet `json:"sets"` + FortniteItems map[string]*FortniteItem `json:"items"` + FortniteItemsWithDisplayAssets map[string]*FortniteItem `json:"-"` + FortniteItemsWithFeaturedImage []*FortniteItem `json:"-"` + TypedFortniteItems map[string][]*FortniteItem `json:"-"` + TypedFortniteItemsWithDisplayAssets map[string][]*FortniteItem `json:"-"` + SnowVariantTokens map[string]SnowCosmeticVariantToken `json:"-"` } func NewExternalDataClient() *ExternalDataClient { diff --git a/handlers/discovery.go b/handlers/discovery.go index b1d6815..e3d312a 100644 --- a/handlers/discovery.go +++ b/handlers/discovery.go @@ -1,11 +1,9 @@ package handlers import ( - "math/rand" "strconv" "github.com/ectrc/snow/aid" - "github.com/ectrc/snow/fortnite" "github.com/gofiber/fiber/v2" ) @@ -75,10 +73,7 @@ func createPlaylist(mnemonic string, image string) aid.JSON { func PostDiscovery(c *fiber.Ctx) error { results := []aid.JSON{} - for playlist := range fortnite.PlaylistImages { - results = append(results, createPlaylist(playlist, "https://" + aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)))) - } - results = append(results, createPlaylist("Playlist_DefaultSolo", "http://bucket.retrac.site/55737fa15677cd57fab9e7f4499d62f89cfde320.png")) + results = append(results, createPlaylist("Playlist_DefaultSolo", "https://bucket.retrac.site/55737fa15677cd57fab9e7f4499d62f89cfde320.png")) return c.Status(200).JSON(aid.JSON{ "Panels": []aid.JSON{ @@ -156,13 +151,13 @@ func GetContentPages(c *fiber.Ctx) error { seasonString := strconv.Itoa(aid.Config.Fortnite.Season) playlists := []aid.JSON{} - for playlist := range fortnite.PlaylistImages { - playlists = append(playlists, aid.JSON{ - "image": "http://" +aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)), - "playlist_name": playlist, - "hidden": false, - }) - } + // for playlist := range fortnite.PlaylistImages { + // playlists = append(playlists, aid.JSON{ + // "image": "http://" +aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)), + // "playlist_name": playlist, + // "hidden": false, + // }) + // } backgrounds := []aid.JSON{} switch aid.Config.Fortnite.Season { diff --git a/handlers/snow.go b/handlers/snow.go index 72f90e3..c9cdcff 100644 --- a/handlers/snow.go +++ b/handlers/snow.go @@ -1,8 +1,6 @@ package handlers import ( - "strings" - "github.com/ectrc/snow/aid" "github.com/ectrc/snow/fortnite" p "github.com/ectrc/snow/person" @@ -10,24 +8,16 @@ import ( "github.com/gofiber/fiber/v2" ) -func GetPreloadedCosmetics(c *fiber.Ctx) error { - return c.JSON(fortnite.External) +func MiddlewareOnlyDebug(c *fiber.Ctx) error { + if aid.Config.API.Debug { + return c.Next() + } + + return c.SendStatus(403) } -func GetPlaylistImage(c *fiber.Ctx) error { - playlist := c.Params("playlist") - if playlist == "" { - return c.SendStatus(404) - } - playlist = strings.Split(playlist, ".")[0] - - image, ok := fortnite.PlaylistImages[playlist] - if !ok { - return c.SendStatus(404) - } - - c.Set("Content-Type", "image/png") - return c.Send(image) +func GetPreloadedCosmetics(c *fiber.Ctx) error { + return c.JSON(fortnite.External) } func GetPlayerLocker(c *fiber.Ctx) error { @@ -68,4 +58,4 @@ func GetSnowConfig(c *fiber.Ctx) error { "basic": aid.Config, "amazon": storage.Repo.Amazon, }) -} \ No newline at end of file +}