From aed4a2ec9839fad05ff0ce2c4d9b757c5814f06d Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Mon, 26 Sep 2022 12:23:33 -0400 Subject: [PATCH] Bug 31627: Add ability to embed the letter id in outgoing email notices It can be useful to know exactly what template was used to generate a notice. To further this end, it would be useful be able to send the letter id as part of any emails sent out if there is a letter template associated with the message. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Generate an email notice like a checkout notice 4) Inspect the email headers, note the new X-Koha-Template-Id and X-Koha-Message-Id headers! Signed-off-by: Sam Lau Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- C4/Letters.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index dc1db2190b..6bc6e870bd 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1293,7 +1293,7 @@ sub _get_unsent_messages { my $dbh = C4::Context->dbh(); my $statement = qq{ - SELECT mq.message_id, mq.borrowernumber, mq.subject, mq.content, mq.message_transport_type, mq.status, mq.time_queued, mq.from_address, mq.reply_address, mq.to_address, mq.content_type, b.branchcode, mq.letter_code, mq.failure_code + SELECT mq.message_id, mq.borrowernumber, mq.subject, mq.content, mq.message_transport_type, mq.status, mq.time_queued, mq.from_address, mq.reply_address, mq.to_address, mq.content_type, b.branchcode, mq.letter_code, mq.failure_code, mq.letter_id FROM message_queue mq LEFT JOIN borrowers b ON b.borrowernumber = mq.borrowernumber WHERE status = ? @@ -1464,6 +1464,8 @@ sub _send_message_by_email { $email->create($params); } else { $email = Koha::Email->create($params); + $email->header('X-Koha-Letter-Id', $message->{letter_id} ); + $email->header('X-Koha-Message-Id', $message->{id} ); if ($is_html) { $email->html_body( _wrap_html( $content, $subject ) ); } else { -- 2.39.5