diff --git a/fortnite/interact.go b/fortnite/interact.go index a4bd440..8dd9b50 100644 --- a/fortnite/interact.go +++ b/fortnite/interact.go @@ -300,11 +300,17 @@ func PreloadCosmetics(max int) error { if err != nil { return err } + withDisplayAssets := 0 for _, asset := range assetData { asset := strings.ReplaceAll(asset, "DAv2_", "") parts := strings.Split(asset, "_") + if strings.Contains(asset, "Bundle") { + withDisplayAssets++ + continue + } + switch { case parts[0] == "CID": addCharacterAsset(parts) @@ -327,7 +333,6 @@ func PreloadCosmetics(max int) error { } } - withDisplayAssets := 0 for _, item := range Cosmetics.Items { if item.DisplayAssetPath2 == "" { continue diff --git a/main.go b/main.go index e74f38b..1e88483 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "github.com/ectrc/snow/fortnite" "github.com/ectrc/snow/handlers" "github.com/ectrc/snow/storage" + "github.com/google/uuid" "github.com/goccy/go-json" "github.com/gofiber/fiber/v2" @@ -41,11 +42,17 @@ func init() { fortnite.GenerateRandomStorefront() if aid.Config.Database.DropAllTables { - username := aid.RandomString(6) - password := aid.RandomString(10) - fortnite.NewFortnitePerson(username, password) + person := fortnite.NewFortnitePerson("ac", "1") - aid.Print("Admin Credentials: username", username, "password", password) + discord := &storage.DB_DiscordPerson{ + ID: uuid.New().String(), + PersonID: person.ID, + } + storage.Repo.SaveDiscordPerson(discord) + + // person.DiscordID = discord.ID + person.Discord = discord + person.Save() } fortnite.GeneratePlaylistImages() diff --git a/person/person.go b/person/person.go index 03f53ce..fe7e2b1 100644 --- a/person/person.go +++ b/person/person.go @@ -15,7 +15,7 @@ type Person struct { Profile0Profile *Profile CollectionsProfile *Profile CreativeProfile *Profile - DiscordID string + // DiscordID string Discord *storage.DB_DiscordPerson } @@ -143,7 +143,7 @@ func findHelper(databasePerson *storage.DB_Person) *Person { CollectionsProfile: collectionsProfile, CreativeProfile: creativeProfile, Discord: &databasePerson.Discord, - DiscordID: databasePerson.DiscordID, + // DiscordID: databasePerson.DiscordID, } cache.SavePerson(person) @@ -204,7 +204,7 @@ func (p *Person) ToDatabase() *storage.DB_Person { Profiles: []storage.DB_Profile{}, Stats: []storage.DB_SeasonStat{}, AccessKey: p.AccessKey, - DiscordID: p.DiscordID, + // DiscordID: p.DiscordID, } if p.Discord != nil { @@ -288,6 +288,6 @@ func (p *Person) Snapshot() *PersonSnapshot { CollectionsProfile: *p.CollectionsProfile.Snapshot(), CreativeProfile: *p.CreativeProfile.Snapshot(), Discord: *p.Discord, - DiscordID: p.DiscordID, + DiscordID: p.Discord.ID, } } \ No newline at end of file diff --git a/storage/postgres.go b/storage/postgres.go index 8d7c4cf..43815e3 100644 --- a/storage/postgres.go +++ b/storage/postgres.go @@ -64,7 +64,7 @@ func (s *PostgresStorage) GetPerson(personId string) *DB_Person { Preload("Profiles.Items"). Preload("Profiles.Gifts"). Preload("Profiles.Quests"). - Preload("Discords"). + Preload("Discord"). Where("id = ?", personId). Find(&dbPerson) @@ -87,7 +87,7 @@ func (s *PostgresStorage) GetPersonByDisplay(displayName string) *DB_Person { Preload("Profiles.Items"). Preload("Profiles.Gifts"). Preload("Profiles.Quests"). - Preload("Discords"). + Preload("Discord"). Where("display_name = ?", displayName). Find(&dbPerson) @@ -98,9 +98,9 @@ func (s *PostgresStorage) GetPersonByDisplay(displayName string) *DB_Person { return &dbPerson } -func (s *PostgresStorage) GetPersonByDiscordID(discorId string) *DB_Person { +func (s *PostgresStorage) GetPersonByDiscordID(discordId string) *DB_Person { var discordEntry DB_DiscordPerson - s.Postgres.Model(&DB_DiscordPerson{}).Where("id = ?", discorId).Find(&discordEntry) + s.Postgres.Model(&DB_DiscordPerson{}).Where("id = ?", discordId).Find(&discordEntry) if discordEntry.ID == "" { return nil @@ -122,7 +122,7 @@ func (s *PostgresStorage) GetAllPersons() []*DB_Person { Preload("Profiles.Items"). Preload("Profiles.Gifts"). Preload("Profiles.Quests"). - Preload("Discords"). + Preload("Discord"). Find(&dbPersons) return dbPersons diff --git a/storage/tables.go b/storage/tables.go index b66b3b6..a7fbae1 100644 --- a/storage/tables.go +++ b/storage/tables.go @@ -12,7 +12,7 @@ type DB_Person struct { AccessKey string Profiles []DB_Profile `gorm:"foreignkey:PersonID"` Stats []DB_SeasonStat `gorm:"foreignkey:PersonID"` - DiscordID string + // DiscordID string Discord DB_DiscordPerson `gorm:"foreignkey:PersonID"` }