diff options
author | Thomas Boerger <thomas@webhippie.de> | 2016-11-27 12:12:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-27 12:12:02 +0100 |
commit | 8347a55cc2a99dadb83d78282c68eb830ea0c144 (patch) | |
tree | 8ba4f7e6b340dc0e9c46c59a5fa80f6889d2905e | |
parent | bc59b8abc9b63b90cd0774680d94c3f70ac85a1a (diff) | |
parent | 066f515a47d024e874408c979732a42bfc72a2a8 (diff) | |
download | gitea-8347a55cc2a99dadb83d78282c68eb830ea0c144.tar.gz gitea-8347a55cc2a99dadb83d78282c68eb830ea0c144.zip |
Merge pull request #263 from Bwko/lint/user_email
Lint models/user_email.go
-rw-r--r-- | models/user_mail.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/models/user_mail.go b/models/user_mail.go index c6ade3fa43..3fc4f4ae89 100644 --- a/models/user_mail.go +++ b/models/user_mail.go @@ -9,7 +9,7 @@ import ( "strings" ) -// EmailAdresses is the list of all email addresses of a user. Can contain the +// EmailAddress is the list of all email addresses of a user. Can contain the // primary email address, but is not obligatory. type EmailAddress struct { ID int64 `xorm:"pk autoincr"` @@ -81,10 +81,12 @@ func addEmailAddress(e Engine, email *EmailAddress) error { return err } +// AddEmailAddress adds an email adress to given user. func AddEmailAddress(email *EmailAddress) error { return addEmailAddress(x, email) } +// AddEmailAddresses adds an email adress to given user. func AddEmailAddresses(emails []*EmailAddress) error { if len(emails) == 0 { return nil @@ -108,6 +110,7 @@ func AddEmailAddresses(emails []*EmailAddress) error { return nil } +// Activate activates the email adress to given user. func (email *EmailAddress) Activate() error { user, err := GetUserByID(email.UID) if err != nil { @@ -134,6 +137,7 @@ func (email *EmailAddress) Activate() error { return sess.Commit() } +// DeleteEmailAddress deletes an email adress of given user. func DeleteEmailAddress(email *EmailAddress) (err error) { if email.ID > 0 { _, err = x.Id(email.ID).Delete(new(EmailAddress)) @@ -145,6 +149,7 @@ func DeleteEmailAddress(email *EmailAddress) (err error) { return err } +// DeleteEmailAddresses deletes multiple email adresses func DeleteEmailAddresses(emails []*EmailAddress) (err error) { for i := range emails { if err = DeleteEmailAddress(emails[i]); err != nil { @@ -155,6 +160,7 @@ func DeleteEmailAddresses(emails []*EmailAddress) (err error) { return nil } +// MakeEmailPrimary sets primary email adress of given user. func MakeEmailPrimary(email *EmailAddress) error { has, err := x.Get(email) if err != nil { |