From 3e58d75b87ab4dd5d352b8e2fc69c1dcd299caf8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 10 Dec 2024 19:18:04 -0800 Subject: [PATCH] userids and asset ids are uint64 --- pkg/model/submission.go | 8 ++++---- pkg/service/security.go | 6 +++--- pkg/service/submissions.go | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkg/model/submission.go b/pkg/model/submission.go index 5fb5a91..ed08173 100644 --- a/pkg/model/submission.go +++ b/pkg/model/submission.go @@ -25,10 +25,10 @@ type Submission struct { GameID int32 CreatedAt time.Time UpdatedAt time.Time - Submitter int64 // UserID - AssetID int64 - AssetVersion int64 + Submitter uint64 // UserID + AssetID uint64 + AssetVersion uint64 Completed bool // Has this version of the map been completed at least once on maptest - TargetAssetID int64 // where to upload map fix. if the TargetAssetID is 0, it's a new map. + TargetAssetID uint64 // where to upload map fix. if the TargetAssetID is 0, it's a new map. StatusID Status } diff --git a/pkg/service/security.go b/pkg/service/security.go index 1a4afe6..1cf09ca 100644 --- a/pkg/service/security.go +++ b/pkg/service/security.go @@ -33,10 +33,10 @@ type Roles struct { type UserInfo struct { Roles Roles - UserID int64 + UserID uint64 } -func (usr UserInfo) IsSubmitter(submitter int64) bool{ +func (usr UserInfo) IsSubmitter(submitter uint64) bool{ return usr.UserID == submitter } @@ -88,7 +88,7 @@ func (svc SecurityHandler) HandleCookieAuth(ctx context.Context, operationName a newCtx := context.WithValue(ctx, "UserInfo", UserInfo{ Roles: roles, - UserID: int64(session.UserID), + UserID: session.UserID, }) return newCtx, nil diff --git a/pkg/service/submissions.go b/pkg/service/submissions.go index bc595d6..160fe46 100644 --- a/pkg/service/submissions.go +++ b/pkg/service/submissions.go @@ -25,11 +25,11 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *api.Submissio DisplayName: request.DisplayName, Creator: request.Creator, GameID: request.GameID, - Submitter: int64(userInfo.UserID), - AssetID: request.AssetID, - AssetVersion: request.AssetVersion, + Submitter: userInfo.UserID, + AssetID: uint64(request.AssetID), + AssetVersion: uint64(request.AssetVersion), Completed: false, - TargetAssetID: request.TargetAssetID.Value, + TargetAssetID: uint64(request.TargetAssetID.Value), StatusID: model.StatusUnderConstruction, }) if err != nil{ @@ -57,11 +57,11 @@ func (svc *Service) GetSubmission(ctx context.Context, params api.GetSubmissionP GameID: submission.GameID, CreatedAt: submission.CreatedAt.Unix(), UpdatedAt: submission.UpdatedAt.Unix(), - Submitter: submission.Submitter, - AssetID: submission.AssetID, - AssetVersion: submission.AssetVersion, + Submitter: int64(submission.Submitter), + AssetID: int64(submission.AssetID), + AssetVersion: int64(submission.AssetVersion), Completed: submission.Completed, - TargetAssetID: api.NewOptInt64(submission.TargetAssetID), + TargetAssetID: api.NewOptInt64(int64(submission.TargetAssetID)), StatusID: int32(submission.StatusID), }, nil } @@ -97,11 +97,11 @@ func (svc *Service) ListSubmissions(ctx context.Context, request api.ListSubmiss GameID: items[i].GameID, CreatedAt: items[i].CreatedAt.Unix(), UpdatedAt: items[i].UpdatedAt.Unix(), - Submitter: items[i].Submitter, - AssetID: items[i].AssetID, - AssetVersion: items[i].AssetVersion, + Submitter: int64(items[i].Submitter), + AssetID: int64(items[i].AssetID), + AssetVersion: int64(items[i].AssetVersion), Completed: items[i].Completed, - TargetAssetID: api.NewOptInt64(items[i].TargetAssetID), + TargetAssetID: api.NewOptInt64(int64(items[i].TargetAssetID)), StatusID: int32(items[i].StatusID), }) }