From: Martin Renvoize Date: Thu, 5 Dec 2019 17:42:50 +0000 (+0000) Subject: Bug 24183: Add before_send_messages hook X-Git-Tag: v20.05.00~718 X-Git-Url: http://git.equinoxoli.org/?p=koha.git;a=commitdiff_plain;h=8a56f176c083f7156584d07af7650162d13814e2 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 --- diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl index 0532a5b..73cbc9a 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,