Bug 24183: Add before_send_messages hook
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 5 Dec 2019 17:42:50 +0000 (17:42 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 6 Apr 2020 09:43:25 +0000 (10:43 +0100)
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 <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

misc/cronjobs/process_message_queue.pl

index 0532a5b..73cbc9a 100755 (executable)
@@ -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,