From 4ed4fcc6bcc259d66388f62904e09c3241cac5cf Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Fri, 2 Dec 2016 16:22:02 +0000
Subject: [PATCH] Bug 15969 - Fetch the message instead of substituting

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 C4/Letters.pm                                          | 2 +-
 misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/C4/Letters.pm b/C4/Letters.pm
index f95af1e938..fddb9542ea 100644
--- a/C4/Letters.pm
+++ b/C4/Letters.pm
@@ -49,7 +49,7 @@ BEGIN {
     require Exporter;
     @ISA = qw(Exporter);
     @EXPORT = qw(
-        &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &SendAlerts &GetPrintMessages &GetMessageTransportTypes
+        &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &SendAlerts &GetPrintMessages &GetMessageTransportTypes &GetMessage
     );
 }
 
diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl
index d5a81ce596..30c65f1c3e 100755
--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl
+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl
@@ -174,8 +174,8 @@ foreach my $type (@types) {
         }
 
         if ( $use_tt ) {
-            $letter->{content} =~ s/__MESSAGE_ID__/$message_id/g;
-            print $OUT $letter->{content};
+            my $message = GetMessage( $message_id );
+            print $OUT $message->{content};
         } else {
             print $OUT "\"$format\",\"$language\",\"$type\",\"$issues->{level}\",\"$issues->{cardnumber}\",\"$issues->{patron_title}\",\"$issues->{firstname}\",";
             print $OUT "\"$issues->{surname}\",\"$issues->{phone}\",\"$issues->{email}\",\"$library_code\",";
-- 
2.24.1 (Apple Git-126)