mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-18 22:36:43 +09:00
Backport #39777 Co-authored-by: Yunus Ozen <94426948+ozenyunus35@users.noreply.github.com>
This commit is contained in:
1 parent
3f0aa7a01e
commit
74e7e813c3
2 files changed
+9
No files matched your search
@@ -1201,6 +1201,9 @@ func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, erro
|
||||
noReplyAddressSuffix := "@" + strings.ToLower(setting.Service.NoReplyAddress)
|
||||
for _, email := range emails {
|
||||
emailLower := strings.ToLower(email)
|
||||
if emailLower == "" {
|
||||
continue // a commit without an author email names no user
|
||||
}
|
||||
needCheckEmails.Add(emailLower)
|
||||
if localPart, ok := strings.CutSuffix(emailLower, noReplyAddressSuffix); ok {
|
||||
name, id := parseLocalPartToNameID(localPart)
|
||||
|
||||
@@ -95,6 +95,12 @@ func TestUserEmails(t *testing.T) {
|
||||
setting.Service.NoReplyAddress = "example.com"
|
||||
testGetUserByEmail(t, "user1-2@example.COM", 1)
|
||||
})
|
||||
|
||||
t.Run("EmptyEmail", func(t *testing.T) {
|
||||
// A user whose email address is empty must not own commits that have no author email.
|
||||
require.NoError(t, db.Insert(t.Context(), &user_model.EmailAddress{UID: 2, Email: "", LowerEmail: "", IsActivated: true}))
|
||||
testGetUserByEmail(t, "", 0)
|
||||
})
|
||||
})
|
||||
t.Run("GetUserByEmail", func(t *testing.T) {
|
||||
testGetUserByEmail := func(t *testing.T, email string, uid int64) {
|
||||
|
||||
Reference in new issue
Block a user