-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make distinction between DisplayName and Username in email templates #6495
Make distinction between DisplayName and Username in email templates #6495
Conversation
Store the actual username in the variable named Username and store the separate DisplayName in another variable. This allows us to access the actual username when we need, which currently fails if a user has set a full name. Fixes go-gitea#6161
Codecov Report
@@ Coverage Diff @@
## master #6495 +/- ##
==========================================
+ Coverage 40.27% 40.28% +0.01%
==========================================
Files 403 403
Lines 54068 54069 +1
==========================================
+ Hits 21775 21781 +6
+ Misses 29276 29270 -6
- Partials 3017 3018 +1
Continue to review full report at Codecov.
|
models/mail.go
Outdated
@@ -47,7 +47,8 @@ func SendTestMail(email string) error { | |||
// SendUserMail sends a mail to the user | |||
func SendUserMail(c *macaron.Context, u *User, tpl base.TplName, code, subject, info string) { | |||
data := map[string]interface{}{ | |||
"Username": u.DisplayName(), | |||
"DisplayName": u.DisplayName(), | |||
"Username": u.DisplayUsername(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be u.Name
, no need for a func.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yes duh 🙈 fixed
models/user.go
Outdated
@@ -650,6 +650,11 @@ func (u *User) DisplayName() string { | |||
return u.Name | |||
} | |||
|
|||
// DisplayUsername returns username | |||
func (u *User) DisplayUsername() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment.
No need for extra function, also change use in all mail sending functions here
Do all the maps actually need both |
True, I guess that is preemptive and if people do want to include the username in the future they can also add it to the map at that time. Appreciate the feedback! |
Store the actual username in the variable named Username and store the separate DisplayName in another variable. This allows us to access the actual username when we need, which currently fails if a user has set a full name.
Fixes #6161