diff --git a/services/mailer/mail_admin_new_user.go b/services/mailer/mail_admin_new_user.go index e6372c5200..e9610e626a 100644 --- a/services/mailer/mail_admin_new_user.go +++ b/services/mailer/mail_admin_new_user.go @@ -51,16 +51,17 @@ func MailNewUser(ctx context.Context, u *user_model.User) { func mailNewUser(ctx context.Context, u *user_model.User, lang string, tos []string) { locale := translation.NewLocale(lang) + manageUserURL := setting.AppURL + "admin/users/" + strconv.FormatInt(u.ID, 10) subject := locale.Tr("mail.admin.new_user.subject", u.Name) - manageUserURL := setting.AppSubURL + "/admin/users/" + strconv.FormatInt(u.ID, 10) body := locale.Tr("mail.admin.new_user.text", manageUserURL) mailMeta := map[string]any{ - "NewUser": u, - "Subject": subject, - "Body": body, - "Language": locale.Language(), - "Locale": locale, - "Str2html": templates.Str2html, + "NewUser": u, + "NewUserUrl": u.HTMLURL(), + "Subject": subject, + "Body": body, + "Language": locale.Language(), + "Locale": locale, + "Str2html": templates.Str2html, } var mailBody bytes.Buffer diff --git a/services/mailer/mail_admin_new_user_test.go b/services/mailer/mail_admin_new_user_test.go index 9e88972ca6..be6ecd9791 100644 --- a/services/mailer/mail_admin_new_user_test.go +++ b/services/mailer/mail_admin_new_user_test.go @@ -57,8 +57,6 @@ func TestAdminNotificationMail_test(t *testing.T) { } setting.MailService = &mailService - setting.Domain = "localhost" - setting.AppSubURL = "http://localhost" // test with SEND_NOTIFICATION_EMAIL_ON_NEW_USER enabled setting.Admin.SendNotificationEmailOnNewUser = true @@ -77,8 +75,9 @@ func TestAdminNotificationMail_test(t *testing.T) { sa = func(msgs ...*Message) { assert.Equal(t, len(msgs), 1, "Test provides only one admin user, so only one email must be sent") assert.Equal(t, msgs[0].To, users[0].Email, "checks if the recipient is the admin of the instance") - manageUserURL := "/admin/users/" + strconv.FormatInt(users[1].ID, 10) + manageUserURL := setting.AppURL + "admin/users/" + strconv.FormatInt(users[1].ID, 10) assert.Contains(t, msgs[0].Body, manageUserURL) + assert.Contains(t, msgs[0].Body, users[1].HTMLURL()) assert.Contains(t, msgs[0].Body, translatedKey, "the .Locale translates to nothing") assert.Contains(t, msgs[0].Body, users[1].Name, "user name of the newly created user") for _, untranslated := range []string{"mail.admin", "admin.users"} { diff --git a/templates/mail/notify/admin_new_user.tmpl b/templates/mail/notify/admin_new_user.tmpl index 07e7a602b2..34d1584f60 100644 --- a/templates/mail/notify/admin_new_user.tmpl +++ b/templates/mail/notify/admin_new_user.tmpl @@ -13,7 +13,7 @@
{{.Body | Str2html}}