From 4bccc966845ae9841937d4114a7e1572576e842d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 28 May 2024 08:20:43 +0200 Subject: [PATCH] mailer: Put the username in X-Forgejo-Sender and -Recipient Following gitea#28981, set `X-Forgejo-Sender` and `X-Forgejo-Recipient` to the username of the respective users, rather than their display name. The username is more appropriate for these headers, for filtering purposes. The display name is already included in the From header. Signed-off-by: Gergely Nagy --- services/mailer/mail.go | 4 ++-- services/mailer/mail_test.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/mailer/mail.go b/services/mailer/mail.go index b04925881d..14fcace1e2 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -415,8 +415,8 @@ func generateAdditionalHeaders(ctx *mailCommentContext, reason string, recipient "X-Gitea-Issue-Link": ctx.Issue.HTMLURL(), "X-Forgejo-Reason": reason, - "X-Forgejo-Sender": ctx.Doer.DisplayName(), - "X-Forgejo-Recipient": recipient.DisplayName(), + "X-Forgejo-Sender": ctx.Doer.Name, + "X-Forgejo-Recipient": recipient.Name, "X-Forgejo-Recipient-Address": recipient.Email, "X-Forgejo-Repository": repo.Name, "X-Forgejo-Repository-Path": repo.FullName(), diff --git a/services/mailer/mail_test.go b/services/mailer/mail_test.go index ed972dbb99..d01d692b61 100644 --- a/services/mailer/mail_test.go +++ b/services/mailer/mail_test.go @@ -369,6 +369,8 @@ func TestGenerateAdditionalHeaders(t *testing.T) { "X-Gitea-Repository-Link": "https://try.gitea.io/user2/repo1", "X-Gitea-Issue-ID": "1", "X-Gitea-Issue-Link": "https://try.gitea.io/user2/repo1/issues/1", + "X-Forgejo-Sender": "user2", + "X-Forgejo-Recipient": "test", } for key, value := range expected {