forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include username in email headers (go-gitea#28981)
Emails from Gitea comments do not contain the username of the commenter anywhere, only their display name, so it is not possible to verify who made a comment from the email itself: From: "Alice" <email@gitea> X-Gitea-Sender: Alice X-Gitea-Recipient: Bob X-GitHub-Sender: Alice X-GitHub-Recipient: Bob This comment looks like it's from @alice. The X-Gitea/X-GitHub headers also use display names, which is not very reliable for filtering, and inconsistent with GitHub's behavior: X-GitHub-Sender: lunny X-GitHub-Recipient: gwymor This change includes both the display name and username in the From header, and switches the other headers from display name to username: From: "Alice (@fakeAlice)" <email@gitea> X-Gitea-Sender: fakealice X-Gitea-Recipient: bob X-GitHub-Sender: fakealice X-GitHub-Recipient: bob This comment looks like it's from @alice.
- Loading branch information
Showing
3 changed files
with
25 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,16 +239,16 @@ func TestGenerateAdditionalHeaders(t *testing.T) { | |
doer, _, issue, _ := prepareMailerTest(t) | ||
|
||
ctx := &mailCommentContext{Context: context.TODO() /* TODO: use a correct context */, Issue: issue, Doer: doer} | ||
recipient := &user_model.User{Name: "Test", Email: "[email protected]"} | ||
recipient := &user_model.User{Name: "test", Email: "[email protected]"} | ||
|
||
headers := generateAdditionalHeaders(ctx, "dummy-reason", recipient) | ||
|
||
expected := map[string]string{ | ||
"List-ID": "user2/repo1 <repo1.user2.localhost>", | ||
"List-Archive": "<https://try.gitea.io/user2/repo1>", | ||
"X-Gitea-Reason": "dummy-reason", | ||
"X-Gitea-Sender": "< U<se>r Tw<o > ><", | ||
"X-Gitea-Recipient": "Test", | ||
"X-Gitea-Sender": "user2", | ||
"X-Gitea-Recipient": "test", | ||
"X-Gitea-Recipient-Address": "[email protected]", | ||
"X-Gitea-Repository": "repo1", | ||
"X-Gitea-Repository-Path": "user2/repo1", | ||
|