1
0
Fork 0
forked from forgejo/forgejo

Move keys to models/asymkey (#17917)

* Move keys to models/keys

* Rename models/keys -> models/asymkey

* change the missed package name

* Fix package alias

* Fix test

* Fix docs

* Fix test

* Fix test

* merge
This commit is contained in:
Lunny Xiao 2021-12-10 16:14:24 +08:00 committed by GitHub
parent 0a9fcf63a4
commit 3ca5dc7e32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 1001 additions and 887 deletions

View file

@ -15,6 +15,7 @@ import (
"strings"
"code.gitea.io/gitea/models"
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
@ -827,7 +828,7 @@ func repoIDMap(ctxUser *user_model.User, issueCountByRepo map[int64]int64, unitT
// ShowSSHKeys output all the ssh keys of user by uid
func ShowSSHKeys(ctx *context.Context, uid int64) {
keys, err := models.ListPublicKeys(uid, db.ListOptions{})
keys, err := asymkey_model.ListPublicKeys(uid, db.ListOptions{})
if err != nil {
ctx.ServerError("ListPublicKeys", err)
return
@ -843,7 +844,7 @@ func ShowSSHKeys(ctx *context.Context, uid int64) {
// ShowGPGKeys output all the public GPG keys of user by uid
func ShowGPGKeys(ctx *context.Context, uid int64) {
keys, err := models.ListGPGKeys(uid, db.ListOptions{})
keys, err := asymkey_model.ListGPGKeys(db.DefaultContext, uid, db.ListOptions{})
if err != nil {
ctx.ServerError("ListGPGKeys", err)
return
@ -851,9 +852,9 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
entities := make([]*openpgp.Entity, 0)
failedEntitiesID := make([]string, 0)
for _, k := range keys {
e, err := models.GPGKeyToEntity(k)
e, err := asymkey_model.GPGKeyToEntity(k)
if err != nil {
if models.IsErrGPGKeyImportNotExist(err) {
if asymkey_model.IsErrGPGKeyImportNotExist(err) {
failedEntitiesID = append(failedEntitiesID, k.KeyID)
continue //Skip previous import without backup of imported armored key
}