fix discord linking in db
This commit is contained in:
parent
fd7a843576
commit
2f6a9d52e4
|
@ -300,11 +300,17 @@ func PreloadCosmetics(max int) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
withDisplayAssets := 0
|
||||||
|
|
||||||
for _, asset := range assetData {
|
for _, asset := range assetData {
|
||||||
asset := strings.ReplaceAll(asset, "DAv2_", "")
|
asset := strings.ReplaceAll(asset, "DAv2_", "")
|
||||||
parts := strings.Split(asset, "_")
|
parts := strings.Split(asset, "_")
|
||||||
|
|
||||||
|
if strings.Contains(asset, "Bundle") {
|
||||||
|
withDisplayAssets++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case parts[0] == "CID":
|
case parts[0] == "CID":
|
||||||
addCharacterAsset(parts)
|
addCharacterAsset(parts)
|
||||||
|
@ -327,7 +333,6 @@ func PreloadCosmetics(max int) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
withDisplayAssets := 0
|
|
||||||
for _, item := range Cosmetics.Items {
|
for _, item := range Cosmetics.Items {
|
||||||
if item.DisplayAssetPath2 == "" {
|
if item.DisplayAssetPath2 == "" {
|
||||||
continue
|
continue
|
||||||
|
|
15
main.go
15
main.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/ectrc/snow/fortnite"
|
"github.com/ectrc/snow/fortnite"
|
||||||
"github.com/ectrc/snow/handlers"
|
"github.com/ectrc/snow/handlers"
|
||||||
"github.com/ectrc/snow/storage"
|
"github.com/ectrc/snow/storage"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"github.com/goccy/go-json"
|
"github.com/goccy/go-json"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
@ -41,11 +42,17 @@ func init() {
|
||||||
fortnite.GenerateRandomStorefront()
|
fortnite.GenerateRandomStorefront()
|
||||||
|
|
||||||
if aid.Config.Database.DropAllTables {
|
if aid.Config.Database.DropAllTables {
|
||||||
username := aid.RandomString(6)
|
person := fortnite.NewFortnitePerson("ac", "1")
|
||||||
password := aid.RandomString(10)
|
|
||||||
fortnite.NewFortnitePerson(username, password)
|
|
||||||
|
|
||||||
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()
|
fortnite.GeneratePlaylistImages()
|
||||||
|
|
|
@ -15,7 +15,7 @@ type Person struct {
|
||||||
Profile0Profile *Profile
|
Profile0Profile *Profile
|
||||||
CollectionsProfile *Profile
|
CollectionsProfile *Profile
|
||||||
CreativeProfile *Profile
|
CreativeProfile *Profile
|
||||||
DiscordID string
|
// DiscordID string
|
||||||
Discord *storage.DB_DiscordPerson
|
Discord *storage.DB_DiscordPerson
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func findHelper(databasePerson *storage.DB_Person) *Person {
|
||||||
CollectionsProfile: collectionsProfile,
|
CollectionsProfile: collectionsProfile,
|
||||||
CreativeProfile: creativeProfile,
|
CreativeProfile: creativeProfile,
|
||||||
Discord: &databasePerson.Discord,
|
Discord: &databasePerson.Discord,
|
||||||
DiscordID: databasePerson.DiscordID,
|
// DiscordID: databasePerson.DiscordID,
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.SavePerson(person)
|
cache.SavePerson(person)
|
||||||
|
@ -204,7 +204,7 @@ func (p *Person) ToDatabase() *storage.DB_Person {
|
||||||
Profiles: []storage.DB_Profile{},
|
Profiles: []storage.DB_Profile{},
|
||||||
Stats: []storage.DB_SeasonStat{},
|
Stats: []storage.DB_SeasonStat{},
|
||||||
AccessKey: p.AccessKey,
|
AccessKey: p.AccessKey,
|
||||||
DiscordID: p.DiscordID,
|
// DiscordID: p.DiscordID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Discord != nil {
|
if p.Discord != nil {
|
||||||
|
@ -288,6 +288,6 @@ func (p *Person) Snapshot() *PersonSnapshot {
|
||||||
CollectionsProfile: *p.CollectionsProfile.Snapshot(),
|
CollectionsProfile: *p.CollectionsProfile.Snapshot(),
|
||||||
CreativeProfile: *p.CreativeProfile.Snapshot(),
|
CreativeProfile: *p.CreativeProfile.Snapshot(),
|
||||||
Discord: *p.Discord,
|
Discord: *p.Discord,
|
||||||
DiscordID: p.DiscordID,
|
DiscordID: p.Discord.ID,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -64,7 +64,7 @@ func (s *PostgresStorage) GetPerson(personId string) *DB_Person {
|
||||||
Preload("Profiles.Items").
|
Preload("Profiles.Items").
|
||||||
Preload("Profiles.Gifts").
|
Preload("Profiles.Gifts").
|
||||||
Preload("Profiles.Quests").
|
Preload("Profiles.Quests").
|
||||||
Preload("Discords").
|
Preload("Discord").
|
||||||
Where("id = ?", personId).
|
Where("id = ?", personId).
|
||||||
Find(&dbPerson)
|
Find(&dbPerson)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ func (s *PostgresStorage) GetPersonByDisplay(displayName string) *DB_Person {
|
||||||
Preload("Profiles.Items").
|
Preload("Profiles.Items").
|
||||||
Preload("Profiles.Gifts").
|
Preload("Profiles.Gifts").
|
||||||
Preload("Profiles.Quests").
|
Preload("Profiles.Quests").
|
||||||
Preload("Discords").
|
Preload("Discord").
|
||||||
Where("display_name = ?", displayName).
|
Where("display_name = ?", displayName).
|
||||||
Find(&dbPerson)
|
Find(&dbPerson)
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ func (s *PostgresStorage) GetPersonByDisplay(displayName string) *DB_Person {
|
||||||
return &dbPerson
|
return &dbPerson
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PostgresStorage) GetPersonByDiscordID(discorId string) *DB_Person {
|
func (s *PostgresStorage) GetPersonByDiscordID(discordId string) *DB_Person {
|
||||||
var discordEntry DB_DiscordPerson
|
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 == "" {
|
if discordEntry.ID == "" {
|
||||||
return nil
|
return nil
|
||||||
|
@ -122,7 +122,7 @@ func (s *PostgresStorage) GetAllPersons() []*DB_Person {
|
||||||
Preload("Profiles.Items").
|
Preload("Profiles.Items").
|
||||||
Preload("Profiles.Gifts").
|
Preload("Profiles.Gifts").
|
||||||
Preload("Profiles.Quests").
|
Preload("Profiles.Quests").
|
||||||
Preload("Discords").
|
Preload("Discord").
|
||||||
Find(&dbPersons)
|
Find(&dbPersons)
|
||||||
|
|
||||||
return dbPersons
|
return dbPersons
|
||||||
|
|
|
@ -12,7 +12,7 @@ type DB_Person struct {
|
||||||
AccessKey string
|
AccessKey string
|
||||||
Profiles []DB_Profile `gorm:"foreignkey:PersonID"`
|
Profiles []DB_Profile `gorm:"foreignkey:PersonID"`
|
||||||
Stats []DB_SeasonStat `gorm:"foreignkey:PersonID"`
|
Stats []DB_SeasonStat `gorm:"foreignkey:PersonID"`
|
||||||
DiscordID string
|
// DiscordID string
|
||||||
Discord DB_DiscordPerson `gorm:"foreignkey:PersonID"`
|
Discord DB_DiscordPerson `gorm:"foreignkey:PersonID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user