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 {
|
||||
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
|
||||
|
|
15
main.go
15
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()
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user