mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-24 03:29:50 +02:00
Merge branch 'main' into fix-24635
This commit is contained in:
9 files changed
+110
-153
No files matched your search
@@ -203,7 +203,7 @@ func composeIssueCommentMessages(ctx context.Context, comment *mailComment, lang
|
||||
msg.SetHeader("References", references...)
|
||||
msg.SetHeader("List-Unsubscribe", listUnsubscribe...)
|
||||
|
||||
for key, value := range generateAdditionalHeadersForIssue(comment, actType, recipient) {
|
||||
for key, value := range generateAdditionalHeadersForIssue(ctx, comment, actType, recipient) {
|
||||
msg.SetHeader(key, value)
|
||||
}
|
||||
|
||||
@@ -303,17 +303,17 @@ func generateMessageIDForIssue(issue *issues_model.Issue, comment *issues_model.
|
||||
return fmt.Sprintf("<%s/%s/%d%s@%s>", issue.Repo.FullName(), path, issue.Index, extra, setting.Domain)
|
||||
}
|
||||
|
||||
func generateAdditionalHeadersForIssue(ctx *mailComment, reason string, recipient *user_model.User) map[string]string {
|
||||
repo := ctx.Issue.Repo
|
||||
func generateAdditionalHeadersForIssue(ctx context.Context, comment *mailComment, reason string, recipient *user_model.User) map[string]string {
|
||||
repo := comment.Issue.Repo
|
||||
|
||||
issueID := strconv.FormatInt(ctx.Issue.Index, 10)
|
||||
issueID := strconv.FormatInt(comment.Issue.Index, 10)
|
||||
headers := generateMetadataHeaders(repo)
|
||||
|
||||
maps.Copy(headers, generateSenderRecipientHeaders(ctx.Doer, recipient))
|
||||
maps.Copy(headers, generateSenderRecipientHeaders(comment.Doer, recipient))
|
||||
maps.Copy(headers, generateReasonHeaders(reason))
|
||||
|
||||
headers["X-Gitea-Issue-ID"] = issueID
|
||||
headers["X-Gitea-Issue-Link"] = ctx.Issue.HTMLURL(context.TODO()) // FIXME: use proper context
|
||||
headers["X-Gitea-Issue-Link"] = comment.Issue.HTMLURL(ctx)
|
||||
headers["X-GitLab-Issue-IID"] = issueID
|
||||
|
||||
return headers
|
||||
|
||||
@@ -304,7 +304,7 @@ func TestGenerateAdditionalHeadersForIssue(t *testing.T) {
|
||||
comment := &mailComment{Issue: issue, Doer: doer}
|
||||
recipient := &user_model.User{Name: "test", Email: "test@gitea.com"}
|
||||
|
||||
headers := generateAdditionalHeadersForIssue(comment, "dummy-reason", recipient)
|
||||
headers := generateAdditionalHeadersForIssue(t.Context(), comment, "dummy-reason", recipient)
|
||||
|
||||
expected := map[string]string{
|
||||
"List-ID": "user2/repo1 <repo1.user2.localhost>",
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"crypto"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -67,7 +68,14 @@ func GetOrCreateKeyPair(ctx context.Context, ownerID int64) (string, string, err
|
||||
}
|
||||
|
||||
func generateKeypair() (string, string, error) {
|
||||
e, err := openpgp.NewEntity("", "Debian Registry", "", nil)
|
||||
// Repository signing keys are long-lived and there is currently no rotation mechanism, choose stronger algorithms
|
||||
cfg := &packet.Config{
|
||||
RSABits: 4096,
|
||||
DefaultHash: crypto.SHA256,
|
||||
DefaultCipher: packet.CipherAES256,
|
||||
}
|
||||
|
||||
e, err := openpgp.NewEntity("", "Automatically generated Debian Registry Key; created "+time.Now().UTC().Format(time.RFC3339), "", cfg)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user