forked from forgejo/forgejo
Move EmailAddress & UserRedirect into models/user/ (#17607)
* Move EmailAddress into models/user/ * Fix test * rename user_mail to user_email * Fix test * Move UserRedirect into models/user/ * Fix lint & test * Fix lint * Fix lint * remove nolint comment * Fix lint
This commit is contained in:
parent
492e1c2fbd
commit
90eb9fb889
32 changed files with 722 additions and 647 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
|
@ -36,7 +37,7 @@ type GPGKey struct {
|
|||
ExpiredUnix timeutil.TimeStamp
|
||||
AddedUnix timeutil.TimeStamp
|
||||
SubsKey []*GPGKey `xorm:"-"`
|
||||
Emails []*EmailAddress
|
||||
Emails []*user_model.EmailAddress
|
||||
Verified bool `xorm:"NOT NULL DEFAULT false"`
|
||||
CanSign bool
|
||||
CanEncryptComms bool
|
||||
|
@ -148,12 +149,12 @@ func parseGPGKey(ownerID int64, e *openpgp.Entity, verified bool) (*GPGKey, erro
|
|||
}
|
||||
|
||||
// Check emails
|
||||
userEmails, err := GetEmailAddresses(ownerID)
|
||||
userEmails, err := user_model.GetEmailAddresses(ownerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
emails := make([]*EmailAddress, 0, len(e.Identities))
|
||||
emails := make([]*user_model.EmailAddress, 0, len(e.Identities))
|
||||
for _, ident := range e.Identities {
|
||||
if ident.Revocation != nil {
|
||||
continue
|
||||
|
@ -242,7 +243,7 @@ func DeleteGPGKey(doer *User, id int64) (err error) {
|
|||
|
||||
func checkKeyEmails(email string, keys ...*GPGKey) (bool, string) {
|
||||
uid := int64(0)
|
||||
var userEmails []*EmailAddress
|
||||
var userEmails []*user_model.EmailAddress
|
||||
var user *User
|
||||
for _, key := range keys {
|
||||
for _, e := range key.Emails {
|
||||
|
@ -252,7 +253,7 @@ func checkKeyEmails(email string, keys ...*GPGKey) (bool, string) {
|
|||
}
|
||||
if key.Verified && key.OwnerID != 0 {
|
||||
if uid != key.OwnerID {
|
||||
userEmails, _ = GetEmailAddresses(key.OwnerID)
|
||||
userEmails, _ = user_model.GetEmailAddresses(key.OwnerID)
|
||||
uid = key.OwnerID
|
||||
user = &User{ID: uid}
|
||||
_, _ = GetUser(user)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue