diff options
author | Joe Chen <jc@unknwon.io> | 2023-02-02 21:14:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-02 21:14:27 +0800 |
commit | 614382fec0ba05149785539ab93560d4d42c194d (patch) | |
tree | 50037ddd412606cfadb278a9c9ea7c4a1eb3d4cc /internal/cmd/serv.go | |
parent | 9df10cb8cc84fbeba9eb603c458078f132a6c201 (diff) |
refactor(db): migrate methods off `user.go` (#7329)
Diffstat (limited to 'internal/cmd/serv.go')
-rw-r--r-- | internal/cmd/serv.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/cmd/serv.go b/internal/cmd/serv.go index 518a52c0..f4ef7020 100644 --- a/internal/cmd/serv.go +++ b/internal/cmd/serv.go @@ -133,6 +133,7 @@ var allowedCommands = map[string]db.AccessMode{ } func runServ(c *cli.Context) error { + ctx := context.Background() setup(c, "serv.log", true) if conf.SSH.Disabled { @@ -161,7 +162,7 @@ func runServ(c *cli.Context) error { repoName := strings.TrimSuffix(strings.ToLower(repoFields[1]), ".git") repoName = strings.TrimSuffix(repoName, ".wiki") - owner, err := db.Users.GetByUsername(context.Background(), ownerName) + owner, err := db.Users.GetByUsername(ctx, ownerName) if err != nil { if db.IsErrUserNotExist(err) { fail("Repository owner does not exist", "Unregistered owner: %s", ownerName) @@ -204,12 +205,12 @@ func runServ(c *cli.Context) error { } checkDeployKey(key, repo) } else { - user, err = db.GetUserByKeyID(key.ID) + user, err = db.Users.GetByKeyID(ctx, key.ID) if err != nil { fail("Internal error", "Failed to get user by key ID '%d': %v", key.ID, err) } - mode := db.Perms.AccessMode(context.Background(), user.ID, repo.ID, + mode := db.Perms.AccessMode(ctx, user.ID, repo.ID, db.AccessModeOptions{ OwnerID: repo.OwnerID, Private: repo.IsPrivate, |