use proper subaddress (#36639)
This commit is contained in:
+5
-3
@@ -213,7 +213,7 @@ func (u *User) SetLastLogin() {
|
|||||||
|
|
||||||
// GetPlaceholderEmail returns an noreply email
|
// GetPlaceholderEmail returns an noreply email
|
||||||
func (u *User) GetPlaceholderEmail() string {
|
func (u *User) GetPlaceholderEmail() string {
|
||||||
return fmt.Sprintf("%s+%d@%s", u.LowerName, u.ID, setting.Service.NoReplyAddress)
|
return fmt.Sprintf("%d+%s@%s", u.ID, u.LowerName, setting.Service.NoReplyAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEmail returns a noreply email, if the user has set to keep his
|
// GetEmail returns a noreply email, if the user has set to keep his
|
||||||
@@ -1279,13 +1279,15 @@ func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, erro
|
|||||||
return &EmailUserMap{results}, nil
|
return &EmailUserMap{results}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseLocalPartToNameID attempts to unparse local-part of email that's in format user+id
|
// parseLocalPartToNameID attempts to unparse local-part of email that's in format id+user
|
||||||
// returns user and id if possible
|
// returns user and id if possible
|
||||||
func parseLocalPartToNameID(localPart string) (string, int64) {
|
func parseLocalPartToNameID(localPart string) (string, int64) {
|
||||||
var id int64
|
var id int64
|
||||||
name, idstr, hasPlus := strings.Cut(localPart, "+")
|
idstr, name, hasPlus := strings.Cut(localPart, "+")
|
||||||
if hasPlus {
|
if hasPlus {
|
||||||
id, _ = strconv.ParseInt(idstr, 10, 64)
|
id, _ = strconv.ParseInt(idstr, 10, 64)
|
||||||
|
} else {
|
||||||
|
name = idstr
|
||||||
}
|
}
|
||||||
return name, id
|
return name, id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ func TestUserEmails(t *testing.T) {
|
|||||||
{"UseR1@example.com", 1},
|
{"UseR1@example.com", 1},
|
||||||
{"user1-2@example.COM", 1},
|
{"user1-2@example.COM", 1},
|
||||||
{"USER2@" + setting.Service.NoReplyAddress, 2},
|
{"USER2@" + setting.Service.NoReplyAddress, 2},
|
||||||
{"user2+2@" + setting.Service.NoReplyAddress, 2},
|
{"2+user2@" + setting.Service.NoReplyAddress, 2},
|
||||||
{"oldUser2UsernameWhichDoesNotMatterForQuery+2@" + setting.Service.NoReplyAddress, 2},
|
{"2+oldUser2UsernameWhichDoesNotMatterForQuery@" + setting.Service.NoReplyAddress, 2},
|
||||||
{"badUser+99999@" + setting.Service.NoReplyAddress, 0},
|
{"99999+badUser@" + setting.Service.NoReplyAddress, 0},
|
||||||
{"user4@example.com", 4},
|
{"user4@example.com", 4},
|
||||||
{"no-such", 0},
|
{"no-such", 0},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ func testEditorWebGitCommitEmail(t *testing.T) {
|
|||||||
t.Run("DefaultEmailKeepPrivate", func(t *testing.T) {
|
t.Run("DefaultEmailKeepPrivate", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
paramsForKeepPrivate["commit_email"] = ""
|
paramsForKeepPrivate["commit_email"] = ""
|
||||||
resp1 = makeReq(t, linkForKeepPrivate, paramsForKeepPrivate, "User Two", "user2+2@noreply.example.org")
|
resp1 = makeReq(t, linkForKeepPrivate, paramsForKeepPrivate, "User Two", "2+user2@noreply.example.org")
|
||||||
})
|
})
|
||||||
t.Run("ChooseEmail", func(t *testing.T) {
|
t.Run("ChooseEmail", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|||||||
@@ -132,14 +132,14 @@ func getExpectedFileResponseForRepoFilesCreate(commitID string, lastCommit *git.
|
|||||||
Author: &api.CommitUser{
|
Author: &api.CommitUser{
|
||||||
Identity: api.Identity{
|
Identity: api.Identity{
|
||||||
Name: "User Two",
|
Name: "User Two",
|
||||||
Email: "user2+2@noreply.example.org",
|
Email: "2+user2@noreply.example.org",
|
||||||
},
|
},
|
||||||
Date: time.Now().UTC().Format(time.RFC3339),
|
Date: time.Now().UTC().Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
Committer: &api.CommitUser{
|
Committer: &api.CommitUser{
|
||||||
Identity: api.Identity{
|
Identity: api.Identity{
|
||||||
Name: "User Two",
|
Name: "User Two",
|
||||||
Email: "user2+2@noreply.example.org",
|
Email: "2+user2@noreply.example.org",
|
||||||
},
|
},
|
||||||
Date: time.Now().UTC().Format(time.RFC3339),
|
Date: time.Now().UTC().Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
@@ -202,14 +202,14 @@ func getExpectedFileResponseForRepoFilesUpdate(commitID, filename, lastCommitSHA
|
|||||||
Author: &api.CommitUser{
|
Author: &api.CommitUser{
|
||||||
Identity: api.Identity{
|
Identity: api.Identity{
|
||||||
Name: "User Two",
|
Name: "User Two",
|
||||||
Email: "user2+2@noreply.example.org",
|
Email: "2+user2@noreply.example.org",
|
||||||
},
|
},
|
||||||
Date: time.Now().UTC().Format(time.RFC3339),
|
Date: time.Now().UTC().Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
Committer: &api.CommitUser{
|
Committer: &api.CommitUser{
|
||||||
Identity: api.Identity{
|
Identity: api.Identity{
|
||||||
Name: "User Two",
|
Name: "User Two",
|
||||||
Email: "user2+2@noreply.example.org",
|
Email: "2+user2@noreply.example.org",
|
||||||
},
|
},
|
||||||
Date: time.Now().UTC().Format(time.RFC3339),
|
Date: time.Now().UTC().Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
@@ -312,13 +312,13 @@ func getExpectedFileResponseForRepoFilesUpdateRename(commitID, lastCommitSHA str
|
|||||||
Author: &api.CommitUser{
|
Author: &api.CommitUser{
|
||||||
Identity: api.Identity{
|
Identity: api.Identity{
|
||||||
Name: "User Two",
|
Name: "User Two",
|
||||||
Email: "user2+2@noreply.example.org",
|
Email: "2+user2@noreply.example.org",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Committer: &api.CommitUser{
|
Committer: &api.CommitUser{
|
||||||
Identity: api.Identity{
|
Identity: api.Identity{
|
||||||
Name: "User Two",
|
Name: "User Two",
|
||||||
Email: "user2+2@noreply.example.org",
|
Email: "2+user2@noreply.example.org",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Parents: []*api.CommitMeta{
|
Parents: []*api.CommitMeta{
|
||||||
|
|||||||
Reference in New Issue
Block a user