Skip to content

Commit 3081e7e

Browse files
authored
Fix missing mail reply address (#27997)
Fixes https://codeberg.org/forgejo/forgejo/issues/1458 Some mails such as issue creation mails are missing the reply-to-comment address. This PR fixes that and specifies which comment types should get a reply-possibility.
1 parent 024fe11 commit 3081e7e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

models/issues/comment.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ func (t CommentType) HasAttachmentSupport() bool {
183183
return false
184184
}
185185

186+
func (t CommentType) HasMailReplySupport() bool {
187+
switch t {
188+
case CommentTypeComment, CommentTypeCode, CommentTypeReview, CommentTypeDismissReview, CommentTypeReopen, CommentTypeClose, CommentTypeMergePull, CommentTypeAssignees:
189+
return true
190+
}
191+
return false
192+
}
193+
186194
// RoleInRepo presents the user's participation in the repo
187195
type RoleInRepo string
188196

services/mailer/mail.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,10 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
290290
reference := createReference(ctx.Issue, nil, activities_model.ActionType(0))
291291

292292
var replyPayload []byte
293-
if ctx.Comment != nil && ctx.Comment.Type == issues_model.CommentTypeCode {
294-
replyPayload, err = incoming_payload.CreateReferencePayload(ctx.Comment)
293+
if ctx.Comment != nil {
294+
if ctx.Comment.Type.HasMailReplySupport() {
295+
replyPayload, err = incoming_payload.CreateReferencePayload(ctx.Comment)
296+
}
295297
} else {
296298
replyPayload, err = incoming_payload.CreateReferencePayload(ctx.Issue)
297299
}
@@ -316,7 +318,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
316318
listUnsubscribe := []string{"<" + ctx.Issue.HTMLURL() + ">"}
317319

318320
if setting.IncomingEmail.Enabled {
319-
if ctx.Comment != nil {
321+
if replyPayload != nil {
320322
token, err := token.CreateToken(token.ReplyHandlerType, recipient, replyPayload)
321323
if err != nil {
322324
log.Error("CreateToken failed: %v", err)

0 commit comments

Comments
 (0)