mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Penultimate round of db.DefaultContext
refactor (#27414)
Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@@ -36,7 +36,7 @@ func UpdateAvatar(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
err = user_service.UploadAvatar(ctx.Doer, content)
|
||||
err = user_service.UploadAvatar(ctx, ctx.Doer, content)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "UploadAvatar", err)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func DeleteAvatar(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
err := user_service.DeleteAvatar(ctx.Doer)
|
||||
err := user_service.DeleteAvatar(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteAvatar", err)
|
||||
}
|
||||
|
@@ -59,14 +59,14 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) {
|
||||
// Querying not just listing
|
||||
if username != "" {
|
||||
// Restrict to provided uid
|
||||
keys, err = asymkey_model.SearchPublicKey(user.ID, fingerprint)
|
||||
keys, err = asymkey_model.SearchPublicKey(ctx, user.ID, fingerprint)
|
||||
} else {
|
||||
// Unrestricted
|
||||
keys, err = asymkey_model.SearchPublicKey(0, fingerprint)
|
||||
keys, err = asymkey_model.SearchPublicKey(ctx, 0, fingerprint)
|
||||
}
|
||||
count = len(keys)
|
||||
} else {
|
||||
total, err2 := asymkey_model.CountPublicKeys(user.ID)
|
||||
total, err2 := asymkey_model.CountPublicKeys(ctx, user.ID)
|
||||
if err2 != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -74,7 +74,7 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) {
|
||||
count = int(total)
|
||||
|
||||
// Use ListPublicKeys
|
||||
keys, err = asymkey_model.ListPublicKeys(user.ID, utils.GetListOptions(ctx))
|
||||
keys, err = asymkey_model.ListPublicKeys(ctx, user.ID, utils.GetListOptions(ctx))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -176,7 +176,7 @@ func GetPublicKey(ctx *context.APIContext) {
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
key, err := asymkey_model.GetPublicKeyByID(ctx.ParamsInt64(":id"))
|
||||
key, err := asymkey_model.GetPublicKeyByID(ctx, ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if asymkey_model.IsErrKeyNotExist(err) {
|
||||
ctx.NotFound()
|
||||
@@ -202,7 +202,7 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
|
||||
return
|
||||
}
|
||||
|
||||
key, err := asymkey_model.AddPublicKey(uid, form.Title, content, 0)
|
||||
key, err := asymkey_model.AddPublicKey(ctx, uid, form.Title, content, 0)
|
||||
if err != nil {
|
||||
repo.HandleAddKeyError(ctx, err)
|
||||
return
|
||||
@@ -262,7 +262,7 @@ func DeletePublicKey(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
id := ctx.ParamsInt64(":id")
|
||||
externallyManaged, err := asymkey_model.PublicKeyIsExternallyManaged(id)
|
||||
externallyManaged, err := asymkey_model.PublicKeyIsExternallyManaged(ctx, id)
|
||||
if err != nil {
|
||||
if asymkey_model.IsErrKeyNotExist(err) {
|
||||
ctx.NotFound()
|
||||
|
Reference in New Issue
Block a user