From 82f6521280ee2730d087f556564644342dd7e6fc Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Quang Date: Tue, 10 Oct 2023 22:02:00 +0700 Subject: [PATCH] :recycle: rename package --- blizzard.go | 6 +- cache/dbg_hook.go | 2 +- cache/store.go | 5 +- cache/stores/buckets.go | 6 +- cache/stores/judge.go | 2 +- cache/stores/pending.go | 2 +- cache/stores/problems.go | 24 ++++++++ cache/stores/users.go | 62 ++++++++++---------- config/config.go | 2 +- cron/cron.go | 2 +- cron/jobs/purge_submissions.go | 8 +-- cron/jobs/update_judge_status.go | 4 +- db/db.go | 4 +- db/debug_hook.go | 2 +- db/models/contest/contest.go | 2 +- db/models/contest/problem.go | 2 +- db/models/contest/submission.go | 2 +- db/models/post/comment.go | 2 +- db/models/post/post.go | 2 +- db/models/user/oauth.go | 2 +- db/models/user/role.go | 2 +- db/seed/seed.go | 8 +-- go.mod | 11 ++-- go.sum | 75 ++++-------------------- judge/judge.go | 2 +- judge/mq_dbg_logger.go | 4 +- judge/result.go | 2 +- judge/worker.go | 56 +++++++++++++----- logger/debug/debug.go | 4 +- logger/logger.go | 2 +- migrations/20230620123717_init.go | 2 +- oauth/oauth.go | 4 +- oauth/providers/discord.go | 4 +- routes/auth/login.go | 6 +- routes/auth/logout.go | 2 +- routes/auth/map.go | 2 +- routes/auth/register.go | 10 ++-- routes/contests/map.go | 2 +- routes/map.go | 20 +++---- routes/oauth/index.go | 10 ++-- routes/oauth/map.go | 2 +- routes/oauth/provider.dynamic.go | 8 +-- routes/oauth/unlink.go | 12 ++-- routes/oauth/validate.go | 16 ++--- routes/posts/index.go | 6 +- routes/posts/map.go | 2 +- routes/problems/index.go | 6 +- routes/problems/map.go | 2 +- routes/problems/problem.dynamic.go | 6 +- routes/problems/submit.go | 18 +++--- routes/root/map.go | 2 +- routes/root/status.go | 6 +- routes/submissions/cancel_submission.go | 4 +- routes/submissions/index.go | 6 +- routes/submissions/map.go | 2 +- routes/submissions/submission.dynamic.go | 4 +- routes/user/api_key.go | 8 +-- routes/user/change_username.go | 2 +- routes/user/index.go | 7 +-- routes/user/info.dynamic.go | 4 +- routes/user/map.go | 2 +- routes/users/index.go | 6 +- routes/users/map.go | 2 +- server/http/context.go | 16 ++++- server/middlewares/auth.go | 19 +++--- server/middlewares/rate_limit.go | 2 +- server/server.go | 10 ++-- server/session/paseto.go | 4 +- storage/storage.go | 4 +- storage/submission.go | 2 +- utils/crypto/hash.go | 2 +- 71 files changed, 288 insertions(+), 275 deletions(-) create mode 100644 cache/stores/problems.go diff --git a/blizzard.go b/blizzard.go index adfe615..edb2475 100644 --- a/blizzard.go +++ b/blizzard.go @@ -1,13 +1,13 @@ package blizzard import ( - "blizzard/cron" - "blizzard/judge" "context" + "github.com/ArcticOJ/blizzard/v0/cron" + "github.com/ArcticOJ/blizzard/v0/judge" ) func Init(ctx context.Context) { - judge.ResponseWorker = judge.NewObserver(ctx) + judge.ResponseWorker = judge.NewWorker(ctx) cron.Start(ctx) go judge.ResponseWorker.Work() } diff --git a/cache/dbg_hook.go b/cache/dbg_hook.go index 16ad3bc..d40855f 100644 --- a/cache/dbg_hook.go +++ b/cache/dbg_hook.go @@ -1,8 +1,8 @@ package cache import ( - "blizzard/logger" "context" + "github.com/ArcticOJ/blizzard/v0/logger" "github.com/redis/go-redis/v9" "net" ) diff --git a/cache/store.go b/cache/store.go index 9350bdd..3e6a53f 100644 --- a/cache/store.go +++ b/cache/store.go @@ -1,10 +1,10 @@ package cache import ( - "blizzard/config" - "blizzard/logger" "context" "fmt" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/logger" "github.com/redis/go-redis/v9" "net" "time" @@ -20,6 +20,7 @@ const ( Bucket Submission Judge + Problem ) func CreateClient(db DB, name string) (c redis.UniversalClient) { diff --git a/cache/stores/buckets.go b/cache/stores/buckets.go index ea8bd8a..cc0137c 100644 --- a/cache/stores/buckets.go +++ b/cache/stores/buckets.go @@ -1,11 +1,11 @@ package stores import ( - "blizzard/cache" - "blizzard/config" - "blizzard/logger" "context" "fmt" + "github.com/ArcticOJ/blizzard/v0/cache" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/logger" "github.com/redis/go-redis/v9" "math" ) diff --git a/cache/stores/judge.go b/cache/stores/judge.go index 7b7640d..6f995fb 100644 --- a/cache/stores/judge.go +++ b/cache/stores/judge.go @@ -1,8 +1,8 @@ package stores import ( - "blizzard/cache" "context" + "github.com/ArcticOJ/blizzard/v0/cache" "github.com/redis/go-redis/v9" "time" ) diff --git a/cache/stores/pending.go b/cache/stores/pending.go index 6102fff..3af8e65 100644 --- a/cache/stores/pending.go +++ b/cache/stores/pending.go @@ -1,9 +1,9 @@ package stores import ( - "blizzard/cache" "context" "fmt" + "github.com/ArcticOJ/blizzard/v0/cache" "github.com/redis/go-redis/v9" "sync" "time" diff --git a/cache/stores/problems.go b/cache/stores/problems.go new file mode 100644 index 0000000..1a95684 --- /dev/null +++ b/cache/stores/problems.go @@ -0,0 +1,24 @@ +package stores + +import ( + "github.com/ArcticOJ/blizzard/v0/cache" + "github.com/ArcticOJ/blizzard/v0/rejson" +) + +var Problems *ProblemStore + +type ProblemStore struct { + j *rejson.ReJSON +} + +const ( + defaultProblemKey = "blizzard::problem[%s]" +) + +func init() { + Problems = &ProblemStore{j: &rejson.ReJSON{Client: cache.CreateClient(cache.Problem, "problems")}} +} + +func (*ProblemStore) Get() { + +} diff --git a/cache/stores/users.go b/cache/stores/users.go index e1695ed..932dd2a 100644 --- a/cache/stores/users.go +++ b/cache/stores/users.go @@ -1,14 +1,13 @@ package stores import ( - "blizzard/cache" - "blizzard/db" - "blizzard/db/models/user" - "blizzard/logger" - "blizzard/rejson" "context" "crypto/md5" "fmt" + "github.com/ArcticOJ/blizzard/v0/cache" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/rejson" "github.com/google/uuid" "github.com/redis/go-redis/v9" "github.com/tmthrgd/go-hex" @@ -24,30 +23,29 @@ type UserStore struct { } const ( - defaultUserListKey = "blizzard::user_list" defaultUserKey = "blizzard::user[%s]" defaultHandleToIdResolver = "blizzard::user_id[%s]" ) func init() { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - defer cancel() + //ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) + //defer cancel() Users = &UserStore{j: &rejson.ReJSON{Client: cache.CreateClient(cache.User, "users")}} - var ids []string - logger.Panic(db.Database.NewSelect().Model((*user.User)(nil)).Column("id").Scan(ctx, &ids), "failed to to query for users") - var m []redis.Z - for _, id := range ids { - m = append(m, redis.Z{ - Score: 0, - Member: id, - }) - } - _, e := Users.j.TxPipelined(ctx, func(p redis.Pipeliner) error { - p.Del(ctx, defaultUserListKey) - p.ZAdd(ctx, defaultUserListKey, m...) - return nil - }) - logger.Panic(e, "failed to populate user cache") + //var ids []string + //logger.Panic(db.Database.NewSelect().Model((*user.User)(nil)).Column("id").Scan(ctx, &ids), "failed to to query for users") + //var m []redis.Z + //for _, id := range ids { + // m = append(m, redis.Z{ + // Score: 0, + // Member: id, + // }) + //} + //_, e := Users.j.TxPipelined(ctx, func(p redis.Pipeliner) error { + // p.Del(ctx, defaultUserListKey) + // p.ZAdd(ctx, defaultUserListKey, m...) + // return nil + //}) + //logger.Panic(e, "failed to populate user cache") } func (s *UserStore) load(id uuid.UUID, handle string) (u *user.User) { @@ -74,9 +72,9 @@ func (s *UserStore) load(id uuid.UUID, handle string) (u *user.User) { return } -func (s *UserStore) Exists(ctx context.Context, id uuid.UUID) bool { - return s.j.ZScore(ctx, defaultUserListKey, id.String()).Err() == nil -} +//func (s *UserStore) Exists(ctx context.Context, id uuid.UUID) bool { +// return s.j.ZScore(ctx, defaultUserListKey, id.String()).Err() == nil +//} func (s *UserStore) fallback(ctx context.Context, id uuid.UUID, handle string) *user.User { u := s.load(id, handle) @@ -111,9 +109,9 @@ func (s *UserStore) Get(ctx context.Context, id uuid.UUID, handle string) *user. } return s.fallback(ctx, uuid.Nil, handle) } - if !s.Exists(ctx, id) { - return nil - } + //if !s.Exists(ctx, id) { + // return nil + //} r := s.j.JSONGet(ctx, fmt.Sprintf(defaultUserKey, id), "$") if _u := rejson.Unmarshal[user.User](r); _u == nil { return s.fallback(ctx, id, "") @@ -146,9 +144,9 @@ func (s *UserStore) GetMinimal(ctx context.Context, id uuid.UUID) *user.MinimalU if id == uuid.Nil { return nil } - if !s.Exists(ctx, id) { - return nil - } + //if !s.Exists(ctx, id) { + // return nil + //} r := s.j.JSONGet(ctx, fmt.Sprintf(defaultUserKey, id), "$['id','displayName','handle','organization','avatar','roles','rating']") res := rejson.Unmarshal[interface{}](r) if res == nil || len(res) != 7 { diff --git a/config/config.go b/config/config.go index 4174363..886bf8f 100644 --- a/config/config.go +++ b/config/config.go @@ -1,7 +1,7 @@ package config import ( - "blizzard/logger" + "github.com/ArcticOJ/blizzard/v0/logger" "github.com/rs/zerolog" "gopkg.in/yaml.v3" "os" diff --git a/cron/cron.go b/cron/cron.go index 5447085..7457a9d 100644 --- a/cron/cron.go +++ b/cron/cron.go @@ -1,8 +1,8 @@ package cron import ( - "blizzard/cron/jobs" "context" + "github.com/ArcticOJ/blizzard/v0/cron/jobs" "github.com/go-co-op/gocron" "sync" "time" diff --git a/cron/jobs/purge_submissions.go b/cron/jobs/purge_submissions.go index 3843791..b3c8183 100644 --- a/cron/jobs/purge_submissions.go +++ b/cron/jobs/purge_submissions.go @@ -1,11 +1,11 @@ package jobs import ( - "blizzard/cache/stores" - "blizzard/db" - "blizzard/db/models/contest" - "blizzard/logger" "context" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/logger" ) func PurgeSubmissions(ctx context.Context) { diff --git a/cron/jobs/update_judge_status.go b/cron/jobs/update_judge_status.go index a9dbcec..5c1d555 100644 --- a/cron/jobs/update_judge_status.go +++ b/cron/jobs/update_judge_status.go @@ -1,11 +1,11 @@ package jobs import ( - "blizzard/cache/stores" - "blizzard/config" "context" "encoding/json" "fmt" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/config" "net/http" "net/url" "time" diff --git a/db/db.go b/db/db.go index 623c072..e293a81 100644 --- a/db/db.go +++ b/db/db.go @@ -1,10 +1,10 @@ package db import ( - "blizzard/config" - "blizzard/db/seed" "database/sql" "fmt" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/db/seed" "github.com/uptrace/bun" "github.com/uptrace/bun/dialect/pgdialect" "github.com/uptrace/bun/driver/pgdriver" diff --git a/db/debug_hook.go b/db/debug_hook.go index 4c7a625..b0b1007 100644 --- a/db/debug_hook.go +++ b/db/debug_hook.go @@ -1,9 +1,9 @@ package db import ( - "blizzard/logger" "context" "errors" + "github.com/ArcticOJ/blizzard/v0/logger" "github.com/uptrace/bun" "reflect" "time" diff --git a/db/models/contest/contest.go b/db/models/contest/contest.go index 4e61657..7b50f63 100644 --- a/db/models/contest/contest.go +++ b/db/models/contest/contest.go @@ -1,7 +1,7 @@ package contest import ( - "blizzard/db/models/user" + "github.com/ArcticOJ/blizzard/v0/db/models/user" ) type ( diff --git a/db/models/contest/problem.go b/db/models/contest/problem.go index cf80bfd..440492c 100644 --- a/db/models/contest/problem.go +++ b/db/models/contest/problem.go @@ -1,7 +1,7 @@ package contest import ( - "blizzard/db/models/user" + "github.com/ArcticOJ/blizzard/v0/db/models/user" "github.com/google/uuid" ) diff --git a/db/models/contest/submission.go b/db/models/contest/submission.go index 7347e0f..887967c 100644 --- a/db/models/contest/submission.go +++ b/db/models/contest/submission.go @@ -1,7 +1,7 @@ package contest import ( - "blizzard/db/models/user" + "github.com/ArcticOJ/blizzard/v0/db/models/user" "github.com/google/uuid" "time" ) diff --git a/db/models/post/comment.go b/db/models/post/comment.go index b84aca4..203a420 100644 --- a/db/models/post/comment.go +++ b/db/models/post/comment.go @@ -1,7 +1,7 @@ package post import ( - "blizzard/db/models/user" + "github.com/ArcticOJ/blizzard/v0/db/models/user" "github.com/google/uuid" "time" ) diff --git a/db/models/post/post.go b/db/models/post/post.go index e4e7191..997ee29 100644 --- a/db/models/post/post.go +++ b/db/models/post/post.go @@ -1,7 +1,7 @@ package post import ( - "blizzard/db/models/user" + "github.com/ArcticOJ/blizzard/v0/db/models/user" "github.com/google/uuid" "time" ) diff --git a/db/models/user/oauth.go b/db/models/user/oauth.go index 3aacd29..9135081 100644 --- a/db/models/user/oauth.go +++ b/db/models/user/oauth.go @@ -1,8 +1,8 @@ package user import ( - "blizzard/db/utils" "context" + "github.com/ArcticOJ/blizzard/v0/db/utils" "github.com/google/uuid" "github.com/uptrace/bun" ) diff --git a/db/models/user/role.go b/db/models/user/role.go index 7b4b94f..3c0c6b1 100644 --- a/db/models/user/role.go +++ b/db/models/user/role.go @@ -1,7 +1,7 @@ package user import ( - "blizzard/permission" + "github.com/ArcticOJ/blizzard/v0/permission" ) type Role struct { diff --git a/db/seed/seed.go b/db/seed/seed.go index f429e0b..32e2a9f 100644 --- a/db/seed/seed.go +++ b/db/seed/seed.go @@ -1,10 +1,10 @@ package seed import ( - "blizzard/db/models/contest" - "blizzard/db/models/post" - "blizzard/db/models/user" "context" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/db/models/post" + "github.com/ArcticOJ/blizzard/v0/db/models/user" "github.com/uptrace/bun" ) @@ -35,7 +35,7 @@ func RegisterModels(db *bun.DB) { func DropAll(db *bun.DB, ctx context.Context) error { m := append(models, intermediaryModels...) for i := range m { - if _, e := db.NewDropTable().Model(m[i]).IfExists().Exec(ctx); e != nil { + if _, e := db.NewDropTable().Model(m[i]).Cascade().IfExists().Exec(ctx); e != nil { return e } } diff --git a/go.mod b/go.mod index 11de140..edd895b 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ -module blizzard +module github.com/ArcticOJ/blizzard/v0 go 1.21 require ( + aidanwoods.dev/go-paseto v1.5.0 github.com/go-co-op/gocron v1.35.0 github.com/go-playground/validator/v10 v10.15.4 - github.com/golang-jwt/jwt/v4 v4.5.0 github.com/google/uuid v1.3.1 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa github.com/labstack/echo/v4 v4.11.1 @@ -28,17 +28,18 @@ require ( ) require ( + aidanwoods.dev/go-result v0.1.0 // indirect + github.com/Jeffail/tunny v0.1.4 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect - github.com/iron-auth/iron-crypto v1.0.0 // indirect - github.com/james-elicx/go-utils v0.2.4 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -46,7 +47,6 @@ require ( github.com/leodido/go-urn v1.2.4 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect - github.com/nitishm/go-rejson/v4 v4.1.0 // indirect github.com/onsi/ginkgo/v2 v2.11.0 // indirect github.com/onsi/gomega v1.27.10 // indirect github.com/pierrec/lz4 v2.6.1+incompatible // indirect @@ -62,6 +62,7 @@ require ( golang.org/x/net v0.15.0 // indirect golang.org/x/sys v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect + golang.org/x/time v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.31.0 // indirect mellium.im/sasl v0.3.1 // indirect diff --git a/go.sum b/go.sum index 449e917..6338fe1 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,13 @@ -github.com/bsm/ginkgo/v2 v2.5.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= +aidanwoods.dev/go-paseto v1.5.0 h1:FKrHrip6HfZfuzLuz2NVnM7wQ3Ql+mKcWWcgDr3Mb1g= +aidanwoods.dev/go-paseto v1.5.0/go.mod h1:9J13iCMdWrkfK1AxAg9QDHLaDMYSEP1ldbFiR+DfmVc= +aidanwoods.dev/go-result v0.1.0 h1:y/BMIRX6q3HwaorX1Wzrjo3WUdiYeyWbvGe18hKS3K8= +aidanwoods.dev/go-result v0.1.0/go.mod h1:yridkWghM7AXSFA6wzx0IbsurIm1Lhuro3rYef8FBHM= +github.com/Jeffail/tunny v0.1.4 h1:chtpdz+nUtaYQeCKlNBg6GycFF/kGVHOr6A3cmzTJXs= +github.com/Jeffail/tunny v0.1.4/go.mod h1:P8xAx4XQl0xsuhjX1DtfaMDCSuavzdb2rwbd0lk+fvo= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= -github.com/bsm/gomega v1.20.0/go.mod h1:JifAceMQ4crZIWYUKrlGcmbN3bqHogVTADMD2ATsbwk= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -16,8 +19,6 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/frankban/quicktest v1.14.2 h1:SPb1KFFmM+ybpEjPUhCCkZOM5xlovT5UbrMvWnXyBns= github.com/frankban/quicktest v1.14.2/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/go-co-op/gocron v1.35.0 h1:niC91OHiSEimXgPPay02AI1gLGL4JGBgDzmWtgZ8n5A= @@ -32,30 +33,17 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs= github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/go-redis/redis/v8 v8.4.4/go.mod h1:nA0bQuF0i5JFx4Ta9RZxGKXFrQ8cRWntra97f0196iY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -63,13 +51,8 @@ github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/iron-auth/iron-crypto v1.0.0 h1:ntfGpzxvKuMCf1ny9C74yHrLjqS2oUNxjhNngV5qcsU= -github.com/iron-auth/iron-crypto v1.0.0/go.mod h1:IxcGw/elH1QqlH5pkHyE+HaOzcDI7TWMqYIjWYHXmag= github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa h1:s+4MhCQ6YrzisK6hFJUX53drDT4UsSW3DEhKn0ifuHw= github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= -github.com/james-elicx/go-utils v0.2.4 h1:eUgWDBpB/g6RQxplOD04uz6SjfSXOQxqp1znG5uZnHg= -github.com/james-elicx/go-utils v0.2.4/go.mod h1:wdeEAS0hLThcKn8f1TL9KbID8o1GgsGGSrV1+8Z5P7E= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= @@ -100,18 +83,8 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/nitishm/go-rejson/v4 v4.1.0/go.mod h1:LG1zga7gFp/GH+0IAbXZ7rM4MJruA8B2dXvmXwV7VZo= -github.com/nitishm/go-rejson/v4 v4.1.1-0.20230331060235-d2aa875760e4 h1:dVFsLEN+NIBKQwy4vC3L/FBAKOxmR3UPciI6adRkxd4= -github.com/nitishm/go-rejson/v4 v4.1.1-0.20230331060235-d2aa875760e4/go.mod h1:m/I9wZpt53OFWhY+uaBFyrbPFKctKaJ5qQnuORQ4LuQ= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.10.4/go.mod h1:g/HbgYopi++010VEqkFgJHKC09uJiW9UkXvMUuKHUCQ= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= @@ -127,7 +100,6 @@ github.com/rabbitmq/rabbitmq-stream-go-client v1.2.1 h1:be/dEkRkVTytjdIVbZrQU0eZ github.com/rabbitmq/rabbitmq-stream-go-client v1.2.1/go.mod h1:6O7+GEY8i29bybaowMhMhb4FWnWzYK6S5xDyxZkHW4U= github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk= github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4= -github.com/redis/go-redis/v9 v9.0.2/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps= github.com/redis/go-redis/v9 v9.2.1 h1:WlYJg71ODF0dVspZZCpYmoF1+U1Jjk9Rwd7pq6QmlCg= github.com/redis/go-redis/v9 v9.2.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= @@ -143,12 +115,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -171,36 +141,21 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9 github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -go.opentelemetry.io/otel v0.15.0/go.mod h1:e4GKElweB8W2gWUqbghw0B8t5MCTccc9212eNHnOHwA= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -210,21 +165,16 @@ golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= @@ -234,11 +184,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/judge/judge.go b/judge/judge.go index 72618ad..2e0e040 100644 --- a/judge/judge.go +++ b/judge/judge.go @@ -1,7 +1,7 @@ package judge import ( - "blizzard/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" ) type ( diff --git a/judge/mq_dbg_logger.go b/judge/mq_dbg_logger.go index 74d1b3a..1ede070 100644 --- a/judge/mq_dbg_logger.go +++ b/judge/mq_dbg_logger.go @@ -1,8 +1,8 @@ package judge import ( - "blizzard/config" - "blizzard/logger" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/logger" amqp "github.com/rabbitmq/amqp091-go" ) diff --git a/judge/result.go b/judge/result.go index 641faa1..ce6f1c2 100644 --- a/judge/result.go +++ b/judge/result.go @@ -1,6 +1,6 @@ package judge -import "blizzard/db/models/contest" +import "github.com/ArcticOJ/blizzard/v0/db/models/contest" type ( CaseVerdict int8 diff --git a/judge/worker.go b/judge/worker.go index c738538..dab00c7 100644 --- a/judge/worker.go +++ b/judge/worker.go @@ -1,16 +1,17 @@ package judge import ( - "blizzard/cache/stores" - "blizzard/config" - "blizzard/db" - "blizzard/db/models/contest" - "blizzard/logger" - "blizzard/utils" "context" "encoding/json" "errors" "fmt" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/logger" + "github.com/ArcticOJ/blizzard/v0/utils" + "github.com/Jeffail/tunny" "github.com/mitchellh/mapstructure" amqp "github.com/rabbitmq/amqp091-go" amqp2 "github.com/rabbitmq/rabbitmq-stream-go-client/pkg/amqp" @@ -22,6 +23,7 @@ import ( "net" "net/http" "net/url" + "runtime" "strconv" "time" ) @@ -50,6 +52,7 @@ type ( mqChan *amqp.Channel mqConn *amqp.Connection env *stream.Environment + pool *tunny.Pool } Subscription struct { @@ -73,10 +76,15 @@ type ( Headers map[string]interface{} Body interface{} } + + consumeParams struct { + id uint32 + name string + } ) -func NewObserver(ctx context.Context) *Worker { - return &Worker{ +func NewWorker(ctx context.Context) (w *Worker) { + w = &Worker{ c: &http.Client{ Timeout: time.Second, }, @@ -90,6 +98,13 @@ func NewObserver(ctx context.Context) *Worker { errChan: make(<-chan *amqp.Error, 1), returnChan: make(<-chan amqp.Return, 1), } + w.pool = tunny.NewFunc(runtime.NumCPU(), func(i interface{}) interface{} { + if p, ok := i.(consumeParams); ok { + return w.consume(p.id, p.name) + } + return nil + }) + return } func (w *Worker) Connect() { @@ -107,10 +122,10 @@ func (w *Worker) Connect() { w.mqChan, e = w.mqConn.Channel() logger.Panic(e, "failed to open a channel for queue") logger.Panic(w.mqChan.ExchangeDeclare("submissions", "direct", true, false, false, false, amqp.Table{ - "x-consumer-timeout": 3600000, + "x-consumer-timeout": time.Hour.Milliseconds(), }), "failed to declare exchange for submissions") logger.Panic(w.mqChan.Qos(100, 0, false), "failed to set qos") - logger.Panic(w.mqChan.ExchangeDeclare("results", "fanout", true, false, false, false, nil), "could not declare exchange for results") + logger.Panic(w.mqChan.ExchangeDeclare("results", "direct", true, false, false, false, nil), "could not declare exchange for results") w.errChan = w.mqConn.NotifyClose(make(chan *amqp.Error, 1)) w.returnChan = w.mqChan.NotifyReturn(make(chan amqp.Return, 1)) w.RecoverResults() @@ -194,7 +209,7 @@ func (w *Worker) Enqueue(sub *Submission, t time.Time) error { w.env.DeleteStream(name) return e } - conf, e := w.mqChan.PublishWithDeferredConfirmWithContext( + e = w.mqChan.PublishWithContext( w.ctx, "submissions", sub.Language, @@ -211,7 +226,7 @@ func (w *Worker) Enqueue(sub *Submission, t time.Time) error { if e != nil { w.env.DeleteStream(name) } - return stores.Pending.Set(w.ctx, sub.ID, conf.DeliveryTag, sub.TestCount, uint16(math.Ceil(float64(sub.Constraints.TimeLimit)))) + return stores.Pending.Set(w.ctx, sub.ID, 0, sub.TestCount, uint16(math.Ceil(float64(sub.Constraints.TimeLimit)))) } @@ -225,13 +240,16 @@ func (w *Worker) Cancel(ctx context.Context, id uint32) error { return errors.New("could not cancel specified submission") } -func (w *Worker) Consume(id uint32, name string) error { +// TODO: figure out a way to avoid race condition as two judges may judge a submission concurrently, wasting resources. + +func (w *Worker) consume(id uint32, name string) bool { lastNonAcVerdict := contest.None _, e := w.env.NewConsumer(name, func(ctx stream.ConsumerContext, msg *amqp2.Message) { var r res if msgpack.Unmarshal(msg.Data[0], &r) != nil { return } + fmt.Println(r.Headers["from"]) if r.Headers["type"] == "final" { ctx.Consumer.Close() var _r FinalResult @@ -257,7 +275,17 @@ func (w *Worker) Consume(id uint32, name string) error { w.publish(id, _r, ttl) } }, stream.NewConsumerOptions().SetOffset(stream.OffsetSpecification{}.First()).SetCRCCheck(false)) - return e + return e == nil +} + +func (w *Worker) Consume(id uint32, name string) error { + if e, ok := w.pool.Process(consumeParams{ + id: id, + name: name, + }).(bool); ok && !e { + return fmt.Errorf("could not start consuming queue '%s'", name) + } + return nil } func (w *Worker) Reconnect() { diff --git a/logger/debug/debug.go b/logger/debug/debug.go index 90bffc4..22bcdf3 100644 --- a/logger/debug/debug.go +++ b/logger/debug/debug.go @@ -1,8 +1,8 @@ package debug import ( - "blizzard/config" - "blizzard/logger" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/logger" ) func Dump(obj ...interface{}) { diff --git a/logger/logger.go b/logger/logger.go index d0212e2..9dfa441 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -30,7 +30,7 @@ func createLogger(scope string) zerolog.Logger { if _t, e := t.Int64(); e != nil { return "" } else { - return "\033[0;36m " + time.UnixMilli(_t).Format("02/01/2006 15:04:05") + "\033[0m" + return "\033[0;36m " + time.UnixMilli(_t).Format("02/01/2006 15:04:05.000") + "\033[0m" } }, FormatMessage: func(i interface{}) string { diff --git a/migrations/20230620123717_init.go b/migrations/20230620123717_init.go index 34d794a..28b1951 100644 --- a/migrations/20230620123717_init.go +++ b/migrations/20230620123717_init.go @@ -1,8 +1,8 @@ package migrations import ( - "blizzard/db/seed" "context" + "github.com/ArcticOJ/blizzard/v0/db/seed" "github.com/uptrace/bun" ) diff --git a/oauth/oauth.go b/oauth/oauth.go index 25e77be..337d735 100644 --- a/oauth/oauth.go +++ b/oauth/oauth.go @@ -1,9 +1,9 @@ package oauth import ( - "blizzard/config" - "blizzard/oauth/providers" "fmt" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/oauth/providers" "golang.org/x/oauth2" "sort" ) diff --git a/oauth/providers/discord.go b/oauth/providers/discord.go index a230b66..49be320 100644 --- a/oauth/providers/discord.go +++ b/oauth/providers/discord.go @@ -1,9 +1,9 @@ package providers import ( - "blizzard/logger/debug" - "blizzard/utils" "fmt" + "github.com/ArcticOJ/blizzard/v0/logger/debug" + "github.com/ArcticOJ/blizzard/v0/utils" "github.com/ravener/discord-oauth2" "net/http" "strings" diff --git a/routes/auth/login.go b/routes/auth/login.go index 41a73d2..7d44554 100644 --- a/routes/auth/login.go +++ b/routes/auth/login.go @@ -1,9 +1,9 @@ package auth import ( - "blizzard/db" - "blizzard/db/models/user" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/server/http" "github.com/matthewhartstonge/argon2" "strings" ) diff --git a/routes/auth/logout.go b/routes/auth/logout.go index bd8f0e4..72306a8 100644 --- a/routes/auth/logout.go +++ b/routes/auth/logout.go @@ -1,7 +1,7 @@ package auth import ( - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/server/http" ) func Logout(ctx *http.Context) http.Response { diff --git a/routes/auth/map.go b/routes/auth/map.go index 6591675..68a1ada 100644 --- a/routes/auth/map.go +++ b/routes/auth/map.go @@ -1,6 +1,6 @@ package auth -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ "/login": { diff --git a/routes/auth/register.go b/routes/auth/register.go index c1bc9c7..890dfb9 100644 --- a/routes/auth/register.go +++ b/routes/auth/register.go @@ -1,11 +1,11 @@ package auth import ( - "blizzard/core" - "blizzard/db" - "blizzard/db/models/user" - "blizzard/server/http" - "blizzard/utils" + "github.com/ArcticOJ/blizzard/v0/core" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/utils" "github.com/jackc/pgerrcode" "github.com/uptrace/bun/driver/pgdriver" "strings" diff --git a/routes/contests/map.go b/routes/contests/map.go index cc05bc0..6c20d84 100644 --- a/routes/contests/map.go +++ b/routes/contests/map.go @@ -1,5 +1,5 @@ package contests -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{} diff --git a/routes/map.go b/routes/map.go index 528fd3a..23cb1c2 100644 --- a/routes/map.go +++ b/routes/map.go @@ -1,16 +1,16 @@ package routes import ( - "blizzard/routes/auth" - "blizzard/routes/contests" - "blizzard/routes/oauth" - "blizzard/routes/posts" - "blizzard/routes/problems" - "blizzard/routes/root" - "blizzard/routes/submissions" - "blizzard/routes/user" - "blizzard/routes/users" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/routes/auth" + "github.com/ArcticOJ/blizzard/v0/routes/contests" + "github.com/ArcticOJ/blizzard/v0/routes/oauth" + "github.com/ArcticOJ/blizzard/v0/routes/posts" + "github.com/ArcticOJ/blizzard/v0/routes/problems" + "github.com/ArcticOJ/blizzard/v0/routes/root" + "github.com/ArcticOJ/blizzard/v0/routes/submissions" + "github.com/ArcticOJ/blizzard/v0/routes/user" + "github.com/ArcticOJ/blizzard/v0/routes/users" + "github.com/ArcticOJ/blizzard/v0/server/http" ) var Map = map[string]http.RouteMap{ diff --git a/routes/oauth/index.go b/routes/oauth/index.go index dca46d5..dc35c57 100644 --- a/routes/oauth/index.go +++ b/routes/oauth/index.go @@ -1,11 +1,11 @@ package oauth import ( - "blizzard/db" - "blizzard/db/models/user" - "blizzard/logger/debug" - "blizzard/oauth" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/logger/debug" + "github.com/ArcticOJ/blizzard/v0/oauth" + "github.com/ArcticOJ/blizzard/v0/server/http" "github.com/google/uuid" "github.com/labstack/echo/v4" ) diff --git a/routes/oauth/map.go b/routes/oauth/map.go index 81fde1e..4525882 100644 --- a/routes/oauth/map.go +++ b/routes/oauth/map.go @@ -1,6 +1,6 @@ package oauth -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ "/": { diff --git a/routes/oauth/provider.dynamic.go b/routes/oauth/provider.dynamic.go index 6d68b6f..ebec65a 100644 --- a/routes/oauth/provider.dynamic.go +++ b/routes/oauth/provider.dynamic.go @@ -1,12 +1,12 @@ package oauth import ( - "blizzard/oauth" - "blizzard/server/http" - "blizzard/utils" - "blizzard/utils/crypto" "encoding/base64" "fmt" + "github.com/ArcticOJ/blizzard/v0/oauth" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/utils" + "github.com/ArcticOJ/blizzard/v0/utils/crypto" "github.com/labstack/echo/v4" "golang.org/x/oauth2" "strings" diff --git a/routes/oauth/unlink.go b/routes/oauth/unlink.go index 9a9edfd..5f18852 100644 --- a/routes/oauth/unlink.go +++ b/routes/oauth/unlink.go @@ -1,12 +1,12 @@ package oauth import ( - "blizzard/db" - "blizzard/db/models/user" - "blizzard/logger/debug" - "blizzard/oauth" - "blizzard/server/http" - "blizzard/utils" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/logger/debug" + "github.com/ArcticOJ/blizzard/v0/oauth" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/utils" ) func Unlink(ctx *http.Context) http.Response { diff --git a/routes/oauth/validate.go b/routes/oauth/validate.go index cd140eb..33b5d60 100644 --- a/routes/oauth/validate.go +++ b/routes/oauth/validate.go @@ -1,16 +1,16 @@ package oauth import ( - "blizzard/db" - "blizzard/db/models/user" - "blizzard/logger/debug" - "blizzard/oauth" - "blizzard/oauth/providers" - "blizzard/server/http" - "blizzard/utils" - "blizzard/utils/crypto" "crypto/hmac" "errors" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/logger/debug" + "github.com/ArcticOJ/blizzard/v0/oauth" + "github.com/ArcticOJ/blizzard/v0/oauth/providers" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/utils" + "github.com/ArcticOJ/blizzard/v0/utils/crypto" "github.com/jackc/pgerrcode" "github.com/labstack/echo/v4" "github.com/uptrace/bun/driver/pgdriver" diff --git a/routes/posts/index.go b/routes/posts/index.go index 1785a16..0fdec32 100644 --- a/routes/posts/index.go +++ b/routes/posts/index.go @@ -1,9 +1,9 @@ package posts import ( - "blizzard/db" - "blizzard/db/models/post" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/post" + "github.com/ArcticOJ/blizzard/v0/server/http" ) func Index(ctx *http.Context) http.Response { diff --git a/routes/posts/map.go b/routes/posts/map.go index 1a24be5..15443e4 100644 --- a/routes/posts/map.go +++ b/routes/posts/map.go @@ -1,6 +1,6 @@ package posts -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ "/": { diff --git a/routes/problems/index.go b/routes/problems/index.go index 7da7692..c0e7f76 100644 --- a/routes/problems/index.go +++ b/routes/problems/index.go @@ -1,9 +1,9 @@ package problems import ( - "blizzard/db" - "blizzard/db/models/contest" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/server/http" ) // TODO: add filters and pagination diff --git a/routes/problems/map.go b/routes/problems/map.go index 913b380..f3de69f 100644 --- a/routes/problems/map.go +++ b/routes/problems/map.go @@ -1,6 +1,6 @@ package problems -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ "/": { diff --git a/routes/problems/problem.dynamic.go b/routes/problems/problem.dynamic.go index 0dd22f6..f896374 100644 --- a/routes/problems/problem.dynamic.go +++ b/routes/problems/problem.dynamic.go @@ -1,9 +1,9 @@ package problems import ( - "blizzard/db" - "blizzard/db/models/contest" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/server/http" ) func Problem(ctx *http.Context) http.Response { diff --git a/routes/problems/submit.go b/routes/problems/submit.go index 06d738e..79f9eaf 100644 --- a/routes/problems/submit.go +++ b/routes/problems/submit.go @@ -3,17 +3,17 @@ package problems import ( - "blizzard/cache/stores" - "blizzard/core" - "blizzard/core/errs" - "blizzard/db" - "blizzard/db/models/contest" - "blizzard/judge" - "blizzard/logger" - "blizzard/server/http" - "blizzard/storage" "context" "errors" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/core" + "github.com/ArcticOJ/blizzard/v0/core/errs" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/judge" + "github.com/ArcticOJ/blizzard/v0/logger" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/storage" "github.com/google/uuid" "path" "strings" diff --git a/routes/root/map.go b/routes/root/map.go index 37a7927..bb72d74 100644 --- a/routes/root/map.go +++ b/routes/root/map.go @@ -1,6 +1,6 @@ package root -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ "/status": { diff --git a/routes/root/status.go b/routes/root/status.go index 95d1d46..2358608 100644 --- a/routes/root/status.go +++ b/routes/root/status.go @@ -1,10 +1,10 @@ package root import ( - "blizzard/build" - "blizzard/cache/stores" - "blizzard/server/http" "encoding/json" + "github.com/ArcticOJ/blizzard/v0/build" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/server/http" "github.com/labstack/echo/v4" ) diff --git a/routes/submissions/cancel_submission.go b/routes/submissions/cancel_submission.go index 66bc02f..f855a92 100644 --- a/routes/submissions/cancel_submission.go +++ b/routes/submissions/cancel_submission.go @@ -1,8 +1,8 @@ package submissions import ( - "blizzard/judge" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/judge" + "github.com/ArcticOJ/blizzard/v0/server/http" "strconv" ) diff --git a/routes/submissions/index.go b/routes/submissions/index.go index 9c672f0..8f1927e 100644 --- a/routes/submissions/index.go +++ b/routes/submissions/index.go @@ -1,9 +1,9 @@ package submissions import ( - "blizzard/db" - "blizzard/db/models/contest" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/contest" + "github.com/ArcticOJ/blizzard/v0/server/http" ) func Submissions(ctx *http.Context) http.Response { diff --git a/routes/submissions/map.go b/routes/submissions/map.go index efe446e..9043aca 100644 --- a/routes/submissions/map.go +++ b/routes/submissions/map.go @@ -1,6 +1,6 @@ package submissions -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ "/": { diff --git a/routes/submissions/submission.dynamic.go b/routes/submissions/submission.dynamic.go index 9b9df9b..a2c6e7a 100644 --- a/routes/submissions/submission.dynamic.go +++ b/routes/submissions/submission.dynamic.go @@ -1,8 +1,8 @@ package submissions import ( - "blizzard/cache/stores" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/server/http" "strconv" ) diff --git a/routes/user/api_key.go b/routes/user/api_key.go index 3c2e7ad..2b728c2 100644 --- a/routes/user/api_key.go +++ b/routes/user/api_key.go @@ -1,11 +1,11 @@ package user import ( - "blizzard/db" - "blizzard/db/models/user" - "blizzard/server/http" - "blizzard/utils" "encoding/base64" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/utils" "github.com/labstack/echo/v4" "strconv" "time" diff --git a/routes/user/change_username.go b/routes/user/change_username.go index c9c9da8..e263bed 100644 --- a/routes/user/change_username.go +++ b/routes/user/change_username.go @@ -1,6 +1,6 @@ package user -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" func ChangeUsername(ctx *http.Context) http.Response { return nil diff --git a/routes/user/index.go b/routes/user/index.go index 6c8b1a0..b0024b7 100644 --- a/routes/user/index.go +++ b/routes/user/index.go @@ -1,16 +1,15 @@ package user import ( - "blizzard/cache/stores" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/server/http" ) func Index(ctx *http.Context) http.Response { if ctx.RequireAuth() { return nil } - if user := stores.Users.GetMinimal(ctx.Request().Context(), ctx.GetUUID()); user != nil { - return ctx.Respond(user) + if u := ctx.GetUser(); u != nil { + return ctx.Respond(u) } return ctx.NotFound("User not found.") } diff --git a/routes/user/info.dynamic.go b/routes/user/info.dynamic.go index 88402e0..c364507 100644 --- a/routes/user/info.dynamic.go +++ b/routes/user/info.dynamic.go @@ -1,8 +1,8 @@ package user import ( - "blizzard/cache/stores" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/server/http" "github.com/google/uuid" ) diff --git a/routes/user/map.go b/routes/user/map.go index 6829461..2e31917 100644 --- a/routes/user/map.go +++ b/routes/user/map.go @@ -1,6 +1,6 @@ package user -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ // avoid conflict with other routes diff --git a/routes/users/index.go b/routes/users/index.go index 0e62ccc..59dd07c 100644 --- a/routes/users/index.go +++ b/routes/users/index.go @@ -1,9 +1,9 @@ package users import ( - "blizzard/db" - "blizzard/db/models/user" - "blizzard/server/http" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/server/http" "github.com/uptrace/bun" ) diff --git a/routes/users/map.go b/routes/users/map.go index b0f1db6..0dc6ec4 100644 --- a/routes/users/map.go +++ b/routes/users/map.go @@ -1,6 +1,6 @@ package users -import "blizzard/server/http" +import "github.com/ArcticOJ/blizzard/v0/server/http" var Map = http.RouteMap{ "/": { diff --git a/server/http/context.go b/server/http/context.go index 4e664fb..4673c22 100644 --- a/server/http/context.go +++ b/server/http/context.go @@ -1,7 +1,8 @@ package http import ( - "blizzard/server/session" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/server/session" "github.com/google/uuid" "github.com/labstack/echo/v4" "net/http" @@ -70,7 +71,7 @@ func (ctx Context) Success() Response { } func (ctx Context) GetUUID() uuid.UUID { - id := ctx.Get("user") + id := ctx.Get("id") if id == nil { return uuid.Nil } @@ -81,6 +82,17 @@ func (ctx Context) GetUUID() uuid.UUID { } } +func (ctx Context) GetUser() *user.MinimalUser { + _u := ctx.Get("user") + if _u == nil { + return nil + } + if u, ok := _u.(*user.MinimalUser); ok { + return u + } + return nil +} + func (ctx Context) PutCookie(name string, value string, exp time.Time, sessionOnly bool) { cookie := new(http.Cookie) cookie.Name = name diff --git a/server/middlewares/auth.go b/server/middlewares/auth.go index c63f477..f22f546 100644 --- a/server/middlewares/auth.go +++ b/server/middlewares/auth.go @@ -1,11 +1,11 @@ package middlewares import ( - "blizzard/cache/stores" - "blizzard/db" - "blizzard/db/models/user" - "blizzard/server/http" - "blizzard/server/session" + "github.com/ArcticOJ/blizzard/v0/cache/stores" + "github.com/ArcticOJ/blizzard/v0/db" + "github.com/ArcticOJ/blizzard/v0/db/models/user" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/server/session" "github.com/google/uuid" "github.com/labstack/echo/v4" "strings" @@ -37,8 +37,13 @@ func Authentication() echo.MiddlewareFunc { if e != nil || cookie.Value == "" { return invalidate(ctx, next) } - if uid := session.Decrypt(cookie.Value); uid != uuid.Nil && stores.Users.Exists(ctx.Request().Context(), uid) { - ctx.Set("user", uid) + if uid := session.Decrypt(cookie.Value); uid != uuid.Nil { + u := stores.Users.GetMinimal(c.Request().Context(), uid) + if u == nil { + return invalidate(ctx, next) + } + ctx.Set("id", uid) + ctx.Set("user", u) } return next(c) } diff --git a/server/middlewares/rate_limit.go b/server/middlewares/rate_limit.go index d4297e0..c6f58ac 100644 --- a/server/middlewares/rate_limit.go +++ b/server/middlewares/rate_limit.go @@ -1,7 +1,7 @@ package middlewares import ( - "blizzard/cache/stores" + "github.com/ArcticOJ/blizzard/v0/cache/stores" "github.com/labstack/echo/v4" "strconv" ) diff --git a/server/server.go b/server/server.go index 9431de9..7f6ba22 100644 --- a/server/server.go +++ b/server/server.go @@ -1,11 +1,11 @@ package server import ( - "blizzard/config" - "blizzard/logger" - "blizzard/routes" - "blizzard/server/http" - "blizzard/server/middlewares" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/logger" + "github.com/ArcticOJ/blizzard/v0/routes" + "github.com/ArcticOJ/blizzard/v0/server/http" + "github.com/ArcticOJ/blizzard/v0/server/middlewares" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" nethttp "net/http" diff --git a/server/session/paseto.go b/server/session/paseto.go index 0f7915a..0f98205 100644 --- a/server/session/paseto.go +++ b/server/session/paseto.go @@ -2,8 +2,8 @@ package session import ( "aidanwoods.dev/go-paseto" - "blizzard/config" - "blizzard/logger" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/logger" "github.com/google/uuid" "time" ) diff --git a/storage/storage.go b/storage/storage.go index 51a0c40..912972e 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -1,8 +1,8 @@ package storage import ( - "blizzard/config" - "blizzard/logger" + "github.com/ArcticOJ/blizzard/v0/config" + "github.com/ArcticOJ/blizzard/v0/logger" "os" ) diff --git a/storage/submission.go b/storage/submission.go index 05fae09..730bf67 100644 --- a/storage/submission.go +++ b/storage/submission.go @@ -1,8 +1,8 @@ package storage import ( - "blizzard/config" "fmt" + "github.com/ArcticOJ/blizzard/v0/config" "io" "mime/multipart" "os" diff --git a/utils/crypto/hash.go b/utils/crypto/hash.go index 353a5c6..be55e61 100644 --- a/utils/crypto/hash.go +++ b/utils/crypto/hash.go @@ -1,9 +1,9 @@ package crypto import ( - "blizzard/config" "crypto/hmac" "crypto/sha256" + "github.com/ArcticOJ/blizzard/v0/config" "hash" )