mirror of
https://github.com/go-gitea/gitea
synced 2025-08-29 12:58:29 +00:00
Fix context usages (#35348)
This commit is contained in:
@@ -56,9 +56,9 @@ func composeIssueCommentMessages(ctx context.Context, comment *mailComment, lang
|
||||
commentType := issues_model.CommentTypeComment
|
||||
if comment.Comment != nil {
|
||||
commentType = comment.Comment.Type
|
||||
link = comment.Issue.HTMLURL() + "#" + comment.Comment.HashTag()
|
||||
link = comment.Issue.HTMLURL(ctx) + "#" + comment.Comment.HashTag()
|
||||
} else {
|
||||
link = comment.Issue.HTMLURL()
|
||||
link = comment.Issue.HTMLURL(ctx)
|
||||
}
|
||||
|
||||
reviewType := issues_model.ReviewTypeComment
|
||||
@@ -175,7 +175,7 @@ func composeIssueCommentMessages(ctx context.Context, comment *mailComment, lang
|
||||
msg.SetHeader("In-Reply-To", reference)
|
||||
|
||||
references := []string{reference}
|
||||
listUnsubscribe := []string{"<" + comment.Issue.HTMLURL() + ">"}
|
||||
listUnsubscribe := []string{"<" + comment.Issue.HTMLURL(ctx) + ">"}
|
||||
|
||||
if setting.IncomingEmail.Enabled {
|
||||
if replyPayload != nil {
|
||||
@@ -313,7 +313,7 @@ func generateAdditionalHeadersForIssue(ctx *mailComment, reason string, recipien
|
||||
maps.Copy(headers, generateReasonHeaders(reason))
|
||||
|
||||
headers["X-Gitea-Issue-ID"] = issueID
|
||||
headers["X-Gitea-Issue-Link"] = ctx.Issue.HTMLURL()
|
||||
headers["X-Gitea-Issue-Link"] = ctx.Issue.HTMLURL(context.TODO()) // FIXME: use proper context
|
||||
headers["X-GitLab-Issue-IID"] = issueID
|
||||
|
||||
return headers
|
||||
|
@@ -150,12 +150,12 @@ func TestComposeIssueComment(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
// text/plain
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`( %s )`, doer.HTMLURL()))
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`( %s )`, issue.HTMLURL()))
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`( %s )`, doer.HTMLURL(t.Context())))
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`( %s )`, issue.HTMLURL(t.Context())))
|
||||
|
||||
// text/html
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`href="%s"`, doer.HTMLURL()))
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`href="%s"`, issue.HTMLURL()))
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`href="%s"`, doer.HTMLURL(t.Context())))
|
||||
assert.Contains(t, string(b), fmt.Sprintf(`href="%s"`, issue.HTMLURL(t.Context())))
|
||||
}
|
||||
|
||||
func TestMailMentionsComment(t *testing.T) {
|
||||
|
@@ -128,7 +128,7 @@ func (m *mailNotifier) IssueChangeAssignee(ctx context.Context, doer *user_model
|
||||
|
||||
func (m *mailNotifier) PullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
|
||||
if isRequest && doer.ID != reviewer.ID && reviewer.EmailNotificationsPreference != user_model.EmailNotificationsDisabled {
|
||||
ct := fmt.Sprintf("Requested to review %s.", issue.HTMLURL())
|
||||
ct := fmt.Sprintf("Requested to review %s.", issue.HTMLURL(ctx))
|
||||
if err := SendIssueAssignedMail(ctx, issue, doer, ct, comment, []*user_model.User{reviewer}); err != nil {
|
||||
log.Error("Error in SendIssueAssignedMail for issue[%d] to reviewer[%d]: %v", issue.ID, reviewer.ID, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user