mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Use FullName in Emails to address the recipient if possible (#31527)
Before we had just the plain mail address as recipient. But now we provide additional Information for the Mail clients. --- *Sponsored by Kithara Software GmbH*
This commit is contained in:
@@ -82,7 +82,7 @@ func sendUserMail(language string, u *user_model.User, tpl base.TplName, code, s
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMessage(u.Email, subject, content.String())
|
||||
msg := NewMessage(u.EmailTo(), subject, content.String())
|
||||
msg.Info = fmt.Sprintf("UID: %d, %s", u.ID, info)
|
||||
|
||||
SendAsync(msg)
|
||||
@@ -158,7 +158,7 @@ func SendRegisterNotifyMail(u *user_model.User) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMessage(u.Email, locale.TrString("mail.register_notify"), content.String())
|
||||
msg := NewMessage(u.EmailTo(), locale.TrString("mail.register_notify"), content.String())
|
||||
msg.Info = fmt.Sprintf("UID: %d, registration notify", u.ID)
|
||||
|
||||
SendAsync(msg)
|
||||
@@ -189,7 +189,7 @@ func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository)
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMessage(u.Email, subject, content.String())
|
||||
msg := NewMessage(u.EmailTo(), subject, content.String())
|
||||
msg.Info = fmt.Sprintf("UID: %d, add collaborator", u.ID)
|
||||
|
||||
SendAsync(msg)
|
||||
|
@@ -40,10 +40,10 @@ func MailNewRelease(ctx context.Context, rel *repo_model.Release) {
|
||||
return
|
||||
}
|
||||
|
||||
langMap := make(map[string][]string)
|
||||
langMap := make(map[string][]*user_model.User)
|
||||
for _, user := range recipients {
|
||||
if user.ID != rel.PublisherID {
|
||||
langMap[user.Language] = append(langMap[user.Language], user.Email)
|
||||
langMap[user.Language] = append(langMap[user.Language], user)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func MailNewRelease(ctx context.Context, rel *repo_model.Release) {
|
||||
}
|
||||
}
|
||||
|
||||
func mailNewRelease(ctx context.Context, lang string, tos []string, rel *repo_model.Release) {
|
||||
func mailNewRelease(ctx context.Context, lang string, tos []*user_model.User, rel *repo_model.Release) {
|
||||
locale := translation.NewLocale(lang)
|
||||
|
||||
var err error
|
||||
@@ -89,7 +89,7 @@ func mailNewRelease(ctx context.Context, lang string, tos []string, rel *repo_mo
|
||||
publisherName := rel.Publisher.DisplayName()
|
||||
msgID := generateMessageIDForRelease(rel)
|
||||
for _, to := range tos {
|
||||
msg := NewMessageFrom(to, publisherName, setting.MailService.FromEmail, subject, mailBody.String())
|
||||
msg := NewMessageFrom(to.EmailTo(), publisherName, setting.MailService.FromEmail, subject, mailBody.String())
|
||||
msg.Info = subject
|
||||
msg.SetHeader("Message-ID", msgID)
|
||||
msgs = append(msgs, msg)
|
||||
|
@@ -28,13 +28,13 @@ func SendRepoTransferNotifyMail(ctx context.Context, doer, newOwner *user_model.
|
||||
return err
|
||||
}
|
||||
|
||||
langMap := make(map[string][]string)
|
||||
langMap := make(map[string][]*user_model.User)
|
||||
for _, user := range users {
|
||||
if !user.IsActive {
|
||||
// don't send emails to inactive users
|
||||
continue
|
||||
}
|
||||
langMap[user.Language] = append(langMap[user.Language], user.Email)
|
||||
langMap[user.Language] = append(langMap[user.Language], user)
|
||||
}
|
||||
|
||||
for lang, tos := range langMap {
|
||||
@@ -46,11 +46,11 @@ func SendRepoTransferNotifyMail(ctx context.Context, doer, newOwner *user_model.
|
||||
return nil
|
||||
}
|
||||
|
||||
return sendRepoTransferNotifyMailPerLang(newOwner.Language, newOwner, doer, []string{newOwner.Email}, repo)
|
||||
return sendRepoTransferNotifyMailPerLang(newOwner.Language, newOwner, doer, []*user_model.User{newOwner}, repo)
|
||||
}
|
||||
|
||||
// sendRepoTransferNotifyMail triggers a notification e-mail when a pending repository transfer was created for each language
|
||||
func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *user_model.User, emails []string, repo *repo_model.Repository) error {
|
||||
func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *user_model.User, emailTos []*user_model.User, repo *repo_model.Repository) error {
|
||||
var (
|
||||
locale = translation.NewLocale(lang)
|
||||
content bytes.Buffer
|
||||
@@ -78,8 +78,8 @@ func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *user_model.U
|
||||
return err
|
||||
}
|
||||
|
||||
for _, to := range emails {
|
||||
msg := NewMessage(to, subject, content.String())
|
||||
for _, to := range emailTos {
|
||||
msg := NewMessage(to.EmailTo(), subject, content.String())
|
||||
msg.Info = fmt.Sprintf("UID: %d, repository pending transfer notification", newOwner.ID)
|
||||
|
||||
SendAsync(msg)
|
||||
|
Reference in New Issue
Block a user