From 165979d87fef0ec18d70d6b3a4bb7797c808794c 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. --- misc/cronjobs/process_message_queue.pl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl index 0532a5b899..a9191f406d 100755 --- a/misc/cronjobs/process_message_queue.pl +++ b/misc/cronjobs/process_message_queue.pl @@ -70,11 +70,28 @@ 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, username => $username, - password => $password, + password => $password, method => $method, limit => $limit, type => $type, -- 2.20.1