Include an In-Reply-To: <Message-ID of triggering e-mail>, if any, in the new_ticket notification. Again

In commit 8a3c9b63b9 ("Include an
 In-Reply-To: <Message-ID of triggering e-mail>, if any,
 in the new_ticket notification") on 2020-07-17,
I made it so the return mail for a ticket submission
is a reply to the submission.

commit dee9e75762 ("todosrht-lmtp:
 Use GraphQL for ticket submission") on 2022-04-05 deletes this.

Why? Unclear. The patch submission in
  https://lists.sr.ht/~sircmpwn/sr.ht-dev/%3C20220405161354.11100-1-me%40adnano.co%3E
says this is the case but doesn't try to justify or rectify it.

Why? Unclear. Add it back because this is basic functionality.
This commit is contained in:
наб 2023-12-31 21:30:19 +01:00 committed by Conrad Hoffmann
parent 11d5155e34
commit 80956c5981
3 changed files with 16 additions and 2 deletions

View File

@ -90,6 +90,7 @@ type EventBuilder struct {
submitterID int
tracker *model.Tracker
ticket *model.Ticket
inReplyTo *string
mentionedParticipants []int
mentions *Mentions
@ -272,6 +273,11 @@ func (builder *EventBuilder) InsertNotifications(eventID int, commentID *int) {
}
}
// Sets the given message ID to be added to In-Reply-To/References headers
func (builder *EventBuilder) InReplyTo(messageId *string) {
builder.inReplyTo = messageId
}
func sendEmail(ctx context.Context, address, message string) error {
return client.Do(ctx, "", "meta.sr.ht", client.GraphQLQuery{
Query: `
@ -363,9 +369,17 @@ func (builder *EventBuilder) SendEmails(subject string,
header.SetAddressList("Reply-To", []*mail.Address{&ticketAddress})
header.SetAddressList("Sender", []*mail.Address{&sender})
if builder.eventType == model.EVENT_CREATED {
if builder.inReplyTo != nil {
header.SetMsgIDList("In-Reply-To", []string{*builder.inReplyTo})
}
header.SetMessageID(ticketRef)
} else {
refs := []string{ticketRef}
if builder.inReplyTo != nil {
refs = append(refs, *builder.inReplyTo)
}
header.SetMsgIDList("In-Reply-To", []string{ticketRef})
header.SetMsgIDList("References", refs)
}
header.SetSubject(subject)
msgBodyWriter, err := mail.CreateSingleInlineWriter(&message, header)

View File

@ -1010,7 +1010,7 @@ func (r *mutationResolver) SubmitTicketEmail(ctx context.Context, trackerID int,
builder.InsertNotifications(eventID, nil)
// TODO: In-Reply-To: {{input.MessageID}}
builder.InReplyTo(&input.MessageID)
details := NewTicketDetails{
Body: ticket.Body,

View File

@ -145,7 +145,7 @@ class MailHandler:
"subject": mail["Subject"],
"body": body,
"senderId": sender.id,
"messageId": mail["Message-ID"],
"messageId": mail["Message-ID"].removeprefix("<").removesuffix(">"),
}
resp = exec_gql("todo.sr.ht", """