From 00e783ff8a6d64f9648fd25812996a82f5c5b2b5 Mon Sep 17 00:00:00 2001 From: Pancakes Date: Tue, 22 Oct 2024 15:50:01 -0400 Subject: [PATCH 1/7] Styling fixes --- api/account/discord.go | 1 + api/account/login.go | 1 + api/daily/common.go | 42 +++++++++++----- api/endpoints.go | 108 ++++++++++++++++++++-------------------- api/savedata/session.go | 17 +++++++ api/savedata/system.go | 17 +++++++ db/account.go | 23 ++++----- db/db.go | 1 + db/savedata.go | 34 ++++++++----- 9 files changed, 152 insertions(+), 92 deletions(-) diff --git a/api/account/discord.go b/api/account/discord.go index bf2a00f..176cb9f 100644 --- a/api/account/discord.go +++ b/api/account/discord.go @@ -41,6 +41,7 @@ func HandleDiscordCallback(w http.ResponseWriter, r *http.Request) (string, erro http.Redirect(w, r, GameURL, http.StatusSeeOther) return "", errors.New("code is empty") } + discordId, err := RetrieveDiscordId(code) if err != nil { http.Redirect(w, r, GameURL, http.StatusSeeOther) diff --git a/api/account/login.go b/api/account/login.go index f9b6034..8eb7d49 100644 --- a/api/account/login.go +++ b/api/account/login.go @@ -75,5 +75,6 @@ func GenerateTokenForUsername(username string) (string, error) { if err != nil { return "", fmt.Errorf("failed to add account session") } + return base64.StdEncoding.EncodeToString(token), nil } diff --git a/api/daily/common.go b/api/daily/common.go index 63353d7..97d897b 100644 --- a/api/daily/common.go +++ b/api/daily/common.go @@ -96,11 +96,7 @@ func Init() error { return nil } - _, err = s3scheduler.AddFunc("@hourly", func() { - time.Sleep(time.Second) - S3SaveMigration() - }) - + _, err = s3scheduler.AddFunc("@hourly", S3SaveMigration) if err != nil { return err } @@ -129,32 +125,52 @@ func S3SaveMigration() { svc := s3.NewFromConfig(cfg, func(o *s3.Options) { o.BaseEndpoint = aws.String(os.Getenv("AWS_ENDPOINT_URL_S3")) }) + // retrieve accounts from db _, err := svc.CreateBucket(context.Background(), &s3.CreateBucketInput{ Bucket: aws.String("pokerogue-system"), }) - if err != nil { log.Printf("error while creating bucket: %s", err) } - accounts := db.RetrieveOldAccounts() + accounts, err := db.RetrieveOldAccounts() + if err != nil { + log.Printf("failed to retrieve old accounts") + return + } + for _, user := range accounts { - data, _ := db.ReadSystemSaveData(user) - username, _ := db.FetchUsernameFromUUID(user) - json, _ := json.Marshal(data) - _, err := svc.PutObject(context.Background(), &s3.PutObjectInput{ + data, err := db.ReadSystemSaveData(user) + if err != nil { + continue + } + + username, err := db.FetchUsernameFromUUID(user) + if err != nil { + continue + } + + json, err := json.Marshal(data) + if err != nil { + continue + } + + _, err = svc.PutObject(context.Background(), &s3.PutObjectInput{ Bucket: aws.String("pokerogue-system"), Key: aws.String(username), Body: bytes.NewReader(json), }) - if err != nil { log.Printf("error while saving data in s3 for user %s: %s", username, err) continue } + err = db.UpdateLocation(user, username) + if err != nil { + continue + } + fmt.Printf("Saved data in s3 for user %s\n", username) - db.UpdateLocation(user, username) } } diff --git a/api/endpoints.go b/api/endpoints.go index 0e9b9bf..e6ad46f 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -751,36 +751,36 @@ func handleAdminDiscordUnlink(w http.ResponseWriter, r *http.Request) { discordId := r.Form.Get("discordId") switch { - case username != "": - log.Printf("Username given, removing discordId") - // this does a quick call to make sure the username exists on the server before allowing the rest of the code to run - // this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server - _, err = db.CheckUsernameExists(username) - if err != nil { - httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound) - return - } + case username != "": + log.Printf("Username given, removing discordId") + // this does a quick call to make sure the username exists on the server before allowing the rest of the code to run + // this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server + _, err = db.CheckUsernameExists(username) + if err != nil { + httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound) + return + } - userUuid, err := db.FetchUUIDFromUsername(username) - if err != nil { - httpError(w, r, err, http.StatusInternalServerError) - return - } + userUuid, err := db.FetchUUIDFromUsername(username) + if err != nil { + httpError(w, r, err, http.StatusInternalServerError) + return + } - err = db.RemoveDiscordIdByUUID(userUuid) - if err != nil { - httpError(w, r, err, http.StatusInternalServerError) - return - } - case discordId != "": - log.Printf("DiscordID given, removing discordId") - err = db.RemoveDiscordIdByDiscordId(discordId) - if err != nil { - httpError(w, r, err, http.StatusInternalServerError) - return - } + err = db.RemoveDiscordIdByUUID(userUuid) + if err != nil { + httpError(w, r, err, http.StatusInternalServerError) + return + } + case discordId != "": + log.Printf("DiscordID given, removing discordId") + err = db.RemoveDiscordIdByDiscordId(discordId) + if err != nil { + httpError(w, r, err, http.StatusInternalServerError) + return + } } - + log.Printf("%s: %s removed discord id %s from username %s", userDiscordId, r.URL.Path, r.Form.Get("discordId"), r.Form.Get("username")) w.WriteHeader(http.StatusOK) @@ -821,7 +821,7 @@ func handleAdminGoogleLink(w http.ResponseWriter, r *http.Request) { httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound) return } - + userUuid, err := db.FetchUUIDFromUsername(username) if err != nil { httpError(w, r, err, http.StatusInternalServerError) @@ -868,34 +868,34 @@ func handleAdminGoogleUnlink(w http.ResponseWriter, r *http.Request) { googleId := r.Form.Get("googleId") switch { - case username != "": - log.Printf("Username given, removing googleId") - // this does a quick call to make sure the username exists on the server before allowing the rest of the code to run - // this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server - _, err = db.CheckUsernameExists(username) - if err != nil { - httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound) - return - } + case username != "": + log.Printf("Username given, removing googleId") + // this does a quick call to make sure the username exists on the server before allowing the rest of the code to run + // this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server + _, err = db.CheckUsernameExists(username) + if err != nil { + httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound) + return + } - userUuid, err := db.FetchUUIDFromUsername(username) - if err != nil { - httpError(w, r, err, http.StatusInternalServerError) - return - } + userUuid, err := db.FetchUUIDFromUsername(username) + if err != nil { + httpError(w, r, err, http.StatusInternalServerError) + return + } - err = db.RemoveGoogleIdByUUID(userUuid) - if err != nil { - httpError(w, r, err, http.StatusInternalServerError) - return - } - case googleId != "": - log.Printf("DiscordID given, removing googleId") - err = db.RemoveGoogleIdByDiscordId(googleId) - if err != nil { - httpError(w, r, err, http.StatusInternalServerError) - return - } + err = db.RemoveGoogleIdByUUID(userUuid) + if err != nil { + httpError(w, r, err, http.StatusInternalServerError) + return + } + case googleId != "": + log.Printf("DiscordID given, removing googleId") + err = db.RemoveGoogleIdByDiscordId(googleId) + if err != nil { + httpError(w, r, err, http.StatusInternalServerError) + return + } } log.Printf("%s: %s removed google id %s from username %s", userDiscordId, r.URL.Path, r.Form.Get("googleId"), r.Form.Get("username")) diff --git a/api/savedata/session.go b/api/savedata/session.go index 78ff85d..d750f7a 100644 --- a/api/savedata/session.go +++ b/api/savedata/session.go @@ -1,3 +1,20 @@ +/* + Copyright (C) 2024 Pagefault Games + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + package savedata import ( diff --git a/api/savedata/system.go b/api/savedata/system.go index 112060b..6c02f2a 100644 --- a/api/savedata/system.go +++ b/api/savedata/system.go @@ -1,3 +1,20 @@ +/* + Copyright (C) 2024 Pagefault Games + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + package savedata import ( diff --git a/db/account.go b/db/account.go index 3ee9633..69c0d94 100644 --- a/db/account.go +++ b/db/account.go @@ -86,7 +86,6 @@ func AddDiscordIdByUUID(discordId string, uuid []byte) error { return nil } - func FetchUsernameByDiscordId(discordId string) (string, error) { var username string err := handle.QueryRow("SELECT username FROM accounts WHERE discordId = ?", discordId).Scan(&username) @@ -200,11 +199,11 @@ func FetchLastLoggedInDateByUsername(username string) (string, error) { } type AdminSearchResponse struct { - Username string `json:"username"` - DiscordId string `json:"discordId"` - GoogleId string `json:"googleId"` - LastLoggedIn string `json:"lastLoggedIn"` - Registered string `json:"registered"` + Username string `json:"username"` + DiscordId string `json:"discordId"` + GoogleId string `json:"googleId"` + LastLoggedIn string `json:"lastLoggedIn"` + Registered string `json:"registered"` } func FetchAdminDetailsByUsername(dbUsername string) (AdminSearchResponse, error) { @@ -217,11 +216,11 @@ func FetchAdminDetailsByUsername(dbUsername string) (AdminSearchResponse, error) } adminResponse = AdminSearchResponse{ - Username: resultUsername.String, - DiscordId: resultDiscordId.String, - GoogleId: resultGoogleId.String, - LastLoggedIn: resultLastLoggedIn.String, - Registered: resultRegistered.String, + Username: resultUsername.String, + DiscordId: resultDiscordId.String, + GoogleId: resultGoogleId.String, + LastLoggedIn: resultLastLoggedIn.String, + Registered: resultRegistered.String, } return adminResponse, nil @@ -478,4 +477,4 @@ func RemoveGoogleIdByDiscordId(discordId string) error { } return nil -} \ No newline at end of file +} diff --git a/db/db.go b/db/db.go index b8b79c0..04fec2d 100644 --- a/db/db.go +++ b/db/db.go @@ -116,5 +116,6 @@ func setupDb(tx *sql.Tx) error { return fmt.Errorf("failed to execute query: %w, query: %s", err, q) } } + return nil } diff --git a/db/savedata.go b/db/savedata.go index aed1eee..a0f3df0 100644 --- a/db/savedata.go +++ b/db/savedata.go @@ -243,7 +243,10 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { } var session defs.SystemSaveData - json.NewDecoder(resp.Body).Decode(&session) + err = json.NewDecoder(resp.Body).Decode(&session) + if err != nil { + return err + } err = StoreSystemSaveData(uuid, session) if err != nil { @@ -262,41 +265,46 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { Bucket: aws.String("pokerogue-system"), Key: aws.String(username), }) - if err != nil { fmt.Printf("Failed to delete object %s from s3: %s\n", username, err) } + return nil } -func RetrieveOldAccounts() [][]byte { +func RetrieveOldAccounts() ([][]byte, error) { var users [][]byte rows, err := handle.Query("SELECT uuid FROM accounts WHERE isInLocalDb = 1 && lastActivity < DATE_SUB(NOW(), INTERVAL 3 MONTH) LIMIT 3000") if err != nil { - return nil + return nil, err } + defer rows.Close() for rows.Next() { var uuid []byte - if err := rows.Scan(&uuid); err != nil { - return nil + err := rows.Scan(&uuid) + if err != nil { + return nil, err } + users = append(users, uuid) } - if err := rows.Err(); err != nil { - return nil - } - return users + return users, nil } -func UpdateLocation(uuid []byte, username string) { +func UpdateLocation(uuid []byte, username string) error { _, err := handle.Exec("UPDATE accounts SET isInLocalDb = 0 WHERE uuid = ?", uuid) if err != nil { fmt.Printf("Failed to update location for user %s\n", username) - return + return err } - DeleteSystemSaveData(uuid) + err = DeleteSystemSaveData(uuid) + if err != nil { + return err + } + + return nil } From c09d27767876b3e6787247a687f962e1b2bd6745 Mon Sep 17 00:00:00 2001 From: Pancakes Date: Tue, 22 Oct 2024 16:12:16 -0400 Subject: [PATCH 2/7] Change more stuff --- api/daily/common.go | 20 +++++++++----------- api/endpoints.go | 3 +-- db/savedata.go | 9 ++++----- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/api/daily/common.go b/api/daily/common.go index 97d897b..c2bc2c6 100644 --- a/api/daily/common.go +++ b/api/daily/common.go @@ -91,18 +91,15 @@ func Init() error { scheduler.Start() - if os.Getenv("AWS_ENDPOINT_URL_S3") == "" { - log.Printf("AWS_ENDPOINT_URL_S3 not set, skipping s3 migration") - return nil - } + if os.Getenv("AWS_ENDPOINT_URL_S3") != "" { + _, err = s3scheduler.AddFunc("@hourly", S3SaveMigration) + if err != nil { + return err + } - _, err = s3scheduler.AddFunc("@hourly", S3SaveMigration) - if err != nil { - return err + s3scheduler.Start() } - s3scheduler.Start() - return nil } @@ -162,15 +159,16 @@ func S3SaveMigration() { Body: bytes.NewReader(json), }) if err != nil { - log.Printf("error while saving data in s3 for user %s: %s", username, err) + log.Printf("error while saving data in S3 for user %s: %s", username, err) continue } err = db.UpdateLocation(user, username) if err != nil { + log.Printf("Failed to update location for user %s: %s", username, err) continue } - fmt.Printf("Saved data in s3 for user %s\n", username) + log.Printf("Saved data in S3 for user %s", username) } } diff --git a/api/endpoints.go b/api/endpoints.go index e6ad46f..478b434 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -420,8 +420,7 @@ func handleSystem(w http.ResponseWriter, r *http.Request) { if errors.Is(err, sql.ErrNoRows) { http.Error(w, err.Error(), http.StatusNotFound) } else { - fmt.Printf("failed to get system save data: %s\n", err) - httpError(w, r, err, http.StatusInternalServerError) + httpError(w, r, fmt.Errorf("failed to get system save data: %s", err), http.StatusInternalServerError) } return diff --git a/db/savedata.go b/db/savedata.go index a0f3df0..1a9488c 100644 --- a/db/savedata.go +++ b/db/savedata.go @@ -22,7 +22,7 @@ import ( "context" "encoding/gob" "encoding/json" - "fmt" + "log" "github.com/klauspost/compress/zstd" "github.com/pagefaultgames/rogueserver/defs" @@ -250,11 +250,11 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { err = StoreSystemSaveData(uuid, session) if err != nil { - fmt.Printf("Failed to store system save data from s3 for user %s\n", username) + log.Printf("Failed to store system save data from s3 for user %s", username) return err } - fmt.Printf("Retrieved system save data from s3 for user %s\n", username) + log.Printf("Retrieved system save data from s3 for user %s", username) _, err = handle.Exec("UPDATE accounts SET isInLocalDb = 1 WHERE uuid = ?", uuid) if err != nil { @@ -266,7 +266,7 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { Key: aws.String(username), }) if err != nil { - fmt.Printf("Failed to delete object %s from s3: %s\n", username, err) + log.Printf("Failed to delete object %s from s3: %s", username, err) } return nil @@ -297,7 +297,6 @@ func RetrieveOldAccounts() ([][]byte, error) { func UpdateLocation(uuid []byte, username string) error { _, err := handle.Exec("UPDATE accounts SET isInLocalDb = 0 WHERE uuid = ?", uuid) if err != nil { - fmt.Printf("Failed to update location for user %s\n", username) return err } From 56ef175646b0b29d0f4c4cf51abfaa9a83aa7288 Mon Sep 17 00:00:00 2001 From: Pancakes Date: Tue, 22 Oct 2024 16:23:54 -0400 Subject: [PATCH 3/7] Get rid of the S3 scheduler --- api/daily/common.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/api/daily/common.go b/api/daily/common.go index c2bc2c6..a51abd6 100644 --- a/api/daily/common.go +++ b/api/daily/common.go @@ -40,9 +40,8 @@ import ( const secondsPerDay = 60 * 60 * 24 var ( - scheduler = cron.New(cron.WithLocation(time.UTC)) - s3scheduler = cron.New(cron.WithLocation(time.UTC)) - secret []byte + scheduler = cron.New(cron.WithLocation(time.UTC)) + secret []byte ) func Init() error { @@ -92,12 +91,14 @@ func Init() error { scheduler.Start() if os.Getenv("AWS_ENDPOINT_URL_S3") != "" { - _, err = s3scheduler.AddFunc("@hourly", S3SaveMigration) - if err != nil { - return err - } - - s3scheduler.Start() + go func() { + for { + err = S3SaveMigration() + if err != nil { + return + } + } + }() } return nil @@ -116,7 +117,7 @@ func deriveSeed(seedTime time.Time) []byte { return hashedSeed[:] } -func S3SaveMigration() { +func S3SaveMigration() error { cfg, _ := config.LoadDefaultConfig(context.TODO()) svc := s3.NewFromConfig(cfg, func(o *s3.Options) { @@ -128,13 +129,12 @@ func S3SaveMigration() { Bucket: aws.String("pokerogue-system"), }) if err != nil { - log.Printf("error while creating bucket: %s", err) + log.Printf("error while creating bucket (already exists?): %s", err) } accounts, err := db.RetrieveOldAccounts() if err != nil { - log.Printf("failed to retrieve old accounts") - return + return fmt.Errorf("failed to retrieve old accounts: %s", err) } for _, user := range accounts { @@ -165,10 +165,12 @@ func S3SaveMigration() { err = db.UpdateLocation(user, username) if err != nil { - log.Printf("Failed to update location for user %s: %s", username, err) + log.Printf("failed to update location for user %s: %s", username, err) continue } - log.Printf("Saved data in S3 for user %s", username) + log.Printf("saved data in S3 for user %s", username) } + + return nil } From a1263e66c6224131dfd92e7d38cf985ae70b7fae Mon Sep 17 00:00:00 2001 From: Pancakes Date: Wed, 23 Oct 2024 05:23:48 -0400 Subject: [PATCH 4/7] Clean up RetrieveSystemSaveFromS3 --- db/savedata.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/db/savedata.go b/db/savedata.go index 1a9488c..3814ead 100644 --- a/db/savedata.go +++ b/db/savedata.go @@ -22,7 +22,7 @@ import ( "context" "encoding/gob" "encoding/json" - "log" + "fmt" "github.com/klauspost/compress/zstd" "github.com/pagefaultgames/rogueserver/defs" @@ -68,8 +68,13 @@ func ReadSystemSaveData(uuid []byte) (defs.SystemSaveData, error) { } if !isLocal { - RetrieveSystemSaveFromS3(uuid) + // writes the data back into the database + err = RetrieveSystemSaveFromS3(uuid) + if err != nil { + return system, err + } } + var data []byte err = handle.QueryRow("SELECT data FROM systemSaveData WHERE uuid = ?", uuid).Scan(&data) if err != nil { @@ -220,6 +225,11 @@ func isSaveInLocalDb(uuid []byte) (bool, error) { } func RetrieveSystemSaveFromS3(uuid []byte) error { + username, err := FetchUsernameFromUUID(uuid) + if err != nil { + return err + } + cfg, err := config.LoadDefaultConfig(context.TODO()) if err != nil { return err @@ -227,17 +237,12 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { client := s3.NewFromConfig(cfg) - username, err := FetchUsernameFromUUID(uuid) - if err != nil { - return err - } - - s3Object := &s3.GetObjectInput{ + s3Object := s3.GetObjectInput{ Bucket: aws.String("pokerogue-system"), Key: aws.String(username), } - resp, err := client.GetObject(context.TODO(), s3Object) + resp, err := client.GetObject(context.TODO(), &s3Object) if err != nil { return err } @@ -250,12 +255,9 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { err = StoreSystemSaveData(uuid, session) if err != nil { - log.Printf("Failed to store system save data from s3 for user %s", username) - return err + return fmt.Errorf("failed to store system save data from S3 for user %s: %s", username, err) } - log.Printf("Retrieved system save data from s3 for user %s", username) - _, err = handle.Exec("UPDATE accounts SET isInLocalDb = 1 WHERE uuid = ?", uuid) if err != nil { return err @@ -266,7 +268,7 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { Key: aws.String(username), }) if err != nil { - log.Printf("Failed to delete object %s from s3: %s", username, err) + return fmt.Errorf("failed to delete object %s from S3: %s", username, err) } return nil From ea4ba75c93cbcc273dbffea84e34396f40009f1a Mon Sep 17 00:00:00 2001 From: Pancakes Date: Wed, 23 Oct 2024 08:28:40 -0400 Subject: [PATCH 5/7] Use AND in SQL query instead of && --- db/savedata.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/savedata.go b/db/savedata.go index 3814ead..4974c4c 100644 --- a/db/savedata.go +++ b/db/savedata.go @@ -276,7 +276,7 @@ func RetrieveSystemSaveFromS3(uuid []byte) error { func RetrieveOldAccounts() ([][]byte, error) { var users [][]byte - rows, err := handle.Query("SELECT uuid FROM accounts WHERE isInLocalDb = 1 && lastActivity < DATE_SUB(NOW(), INTERVAL 3 MONTH) LIMIT 3000") + rows, err := handle.Query("SELECT uuid FROM accounts WHERE isInLocalDb = 1 AND lastActivity < DATE_SUB(NOW(), INTERVAL 3 MONTH) LIMIT 3000") if err != nil { return nil, err } From cf2abd4f20ecb79fb123a8a7a23d6f8a3f49b25b Mon Sep 17 00:00:00 2001 From: Pancakes Date: Wed, 23 Oct 2024 09:23:24 -0400 Subject: [PATCH 6/7] Remove AWS_REGION --- api/daily/common.go | 2 +- docker-compose.Example.yml | 1 - rogueserver.go | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/daily/common.go b/api/daily/common.go index a51abd6..521bf53 100644 --- a/api/daily/common.go +++ b/api/daily/common.go @@ -124,7 +124,6 @@ func S3SaveMigration() error { o.BaseEndpoint = aws.String(os.Getenv("AWS_ENDPOINT_URL_S3")) }) - // retrieve accounts from db _, err := svc.CreateBucket(context.Background(), &s3.CreateBucketInput{ Bucket: aws.String("pokerogue-system"), }) @@ -132,6 +131,7 @@ func S3SaveMigration() error { log.Printf("error while creating bucket (already exists?): %s", err) } + // retrieve accounts from db accounts, err := db.RetrieveOldAccounts() if err != nil { return fmt.Errorf("failed to retrieve old accounts: %s", err) diff --git a/docker-compose.Example.yml b/docker-compose.Example.yml index 289e074..1951729 100644 --- a/docker-compose.Example.yml +++ b/docker-compose.Example.yml @@ -12,7 +12,6 @@ services: callbackurl: http://localhost:8001 AWS_ACCESS_KEY_ID: AWS_SECRET_ACCESS_KEY: - AWS_REGION: AWS_ENDPOINT_URL_S3: depends_on: diff --git a/rogueserver.go b/rogueserver.go index c54c6de..b69631d 100644 --- a/rogueserver.go +++ b/rogueserver.go @@ -70,6 +70,7 @@ func main() { account.GoogleCallbackURL = callbackurl + "/auth/google/callback" account.DiscordSession, _ = discordgo.New("Bot " + discordbottoken) account.DiscordGuildID = discordguildid + // register gob types gob.Register([]interface{}{}) gob.Register(map[string]interface{}{}) From 07bd7fc1d1737639738bbed518c105c2e0222ea6 Mon Sep 17 00:00:00 2001 From: Pancakes Date: Wed, 23 Oct 2024 09:35:07 -0400 Subject: [PATCH 7/7] Add AWS_REGION back, keep other changes --- docker-compose.Example.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.Example.yml b/docker-compose.Example.yml index 1951729..289e074 100644 --- a/docker-compose.Example.yml +++ b/docker-compose.Example.yml @@ -12,6 +12,7 @@ services: callbackurl: http://localhost:8001 AWS_ACCESS_KEY_ID: AWS_SECRET_ACCESS_KEY: + AWS_REGION: AWS_ENDPOINT_URL_S3: depends_on: