diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2024-02-14 18:50:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 12:50:10 -0500 |
commit | 155269fa586c41a268530c3bb56349e68e6761d7 (patch) | |
tree | 6164c1178e95e3aec7d09f07af02ae0ae6d3ec02 /models | |
parent | d0183dfa49125a9e533dbe8beab4d8a3724a4f07 (diff) | |
download | gitea-155269fa586c41a268530c3bb56349e68e6761d7.tar.gz gitea-155269fa586c41a268530c3bb56349e68e6761d7.zip |
Remove unused `KeyID`. (#29167)
`KeyID` is never set.
Diffstat (limited to 'models')
-rw-r--r-- | models/organization/org.go | 4 | ||||
-rw-r--r-- | models/user/email_address.go | 4 | ||||
-rw-r--r-- | models/user/error.go | 7 | ||||
-rw-r--r-- | models/user/user.go | 14 |
4 files changed, 12 insertions, 17 deletions
diff --git a/models/organization/org.go b/models/organization/org.go index 23a4e2f96a..b4919defb4 100644 --- a/models/organization/org.go +++ b/models/organization/org.go @@ -594,9 +594,7 @@ func GetOrgByID(ctx context.Context, id int64) (*Organization, error) { return nil, err } else if !has { return nil, user_model.ErrUserNotExist{ - UID: id, - Name: "", - KeyID: 0, + UID: id, } } return u, nil diff --git a/models/user/email_address.go b/models/user/email_address.go index 957e72fe89..216840916d 100644 --- a/models/user/email_address.go +++ b/models/user/email_address.go @@ -332,9 +332,7 @@ func MakeEmailPrimary(ctx context.Context, email *EmailAddress) error { return err } else if !has { return ErrUserNotExist{ - UID: email.UID, - Name: "", - KeyID: 0, + UID: email.UID, } } diff --git a/models/user/error.go b/models/user/error.go index ef572c178a..cbf19998d1 100644 --- a/models/user/error.go +++ b/models/user/error.go @@ -31,9 +31,8 @@ func (err ErrUserAlreadyExist) Unwrap() error { // ErrUserNotExist represents a "UserNotExist" kind of error. type ErrUserNotExist struct { - UID int64 - Name string - KeyID int64 + UID int64 + Name string } // IsErrUserNotExist checks if an error is a ErrUserNotExist. @@ -43,7 +42,7 @@ func IsErrUserNotExist(err error) bool { } func (err ErrUserNotExist) Error() string { - return fmt.Sprintf("user does not exist [uid: %d, name: %s, keyid: %d]", err.UID, err.Name, err.KeyID) + return fmt.Sprintf("user does not exist [uid: %d, name: %s]", err.UID, err.Name) } // Unwrap unwraps this error as a ErrNotExist error diff --git a/models/user/user.go b/models/user/user.go index 536ec78a0b..f31dfb76bb 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -835,7 +835,7 @@ func GetUserByID(ctx context.Context, id int64) (*User, error) { if err != nil { return nil, err } else if !has { - return nil, ErrUserNotExist{id, "", 0} + return nil, ErrUserNotExist{UID: id} } return u, nil } @@ -885,14 +885,14 @@ func GetPossibleUserByIDs(ctx context.Context, ids []int64) ([]*User, error) { // GetUserByNameCtx returns user by given name. func GetUserByName(ctx context.Context, name string) (*User, error) { if len(name) == 0 { - return nil, ErrUserNotExist{0, name, 0} + return nil, ErrUserNotExist{Name: name} } u := &User{LowerName: strings.ToLower(name), Type: UserTypeIndividual} has, err := db.GetEngine(ctx).Get(u) if err != nil { return nil, err } else if !has { - return nil, ErrUserNotExist{0, name, 0} + return nil, ErrUserNotExist{Name: name} } return u, nil } @@ -1033,7 +1033,7 @@ func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) [] // GetUserByEmail returns the user object by given e-mail if exists. func GetUserByEmail(ctx context.Context, email string) (*User, error) { if len(email) == 0 { - return nil, ErrUserNotExist{0, email, 0} + return nil, ErrUserNotExist{Name: email} } email = strings.ToLower(email) @@ -1060,7 +1060,7 @@ func GetUserByEmail(ctx context.Context, email string) (*User, error) { } } - return nil, ErrUserNotExist{0, email, 0} + return nil, ErrUserNotExist{Name: email} } // GetUser checks if a user already exists @@ -1071,7 +1071,7 @@ func GetUser(ctx context.Context, user *User) (bool, error) { // GetUserByOpenID returns the user object by given OpenID if exists. func GetUserByOpenID(ctx context.Context, uri string) (*User, error) { if len(uri) == 0 { - return nil, ErrUserNotExist{0, uri, 0} + return nil, ErrUserNotExist{Name: uri} } uri, err := openid.Normalize(uri) @@ -1091,7 +1091,7 @@ func GetUserByOpenID(ctx context.Context, uri string) (*User, error) { return GetUserByID(ctx, oid.UID) } - return nil, ErrUserNotExist{0, uri, 0} + return nil, ErrUserNotExist{Name: uri} } // GetAdminUser returns the first administrator |