From 8a56f176c083f7156584d07af7650162d13814e2 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 5 Dec 2019 17:42:50 +0000 Subject: [PATCH] Bug 24183: Add before_send_messages hook This patch adds a simple hook to the process_message_queue cronjob to allow plugins to pre-process messages in the messaging queue before they are sent. Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- misc/cronjobs/process_message_queue.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl index 0532a5b899..73cbc9a7ac 100755 --- a/misc/cronjobs/process_message_queue.pl +++ b/misc/cronjobs/process_message_queue.pl @@ -70,6 +70,23 @@ die $usage if $help; cronlogaction(); +if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) { + my @plugins = Koha::Plugins->new->GetPlugins({ + method => 'before_send_messages', + }); + + if (@plugins) { + foreach my $plugin ( @plugins ) { + try { + $plugin->before_send_messages(); + } + catch { + warn "$_"; + }; + } + } +} + C4::Letters::SendQueuedMessages( { verbose => $verbose, -- 2.39.5