From e6b39bb00508b03385fd11f7bc9db9dc5c8ade27 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 30 Mar 2023 08:58:10 +0200 Subject: [PATCH] Bug 33360: Incorporate Koha::Notice::Util in Letters:SendQueuedMessages Content-Type: text/plain; charset=utf-8 --- C4/Letters.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C4/Letters.pm b/C4/Letters.pm index 36d3f5d77e..f8724eab2a 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -34,6 +34,7 @@ use Koha::SMS::Providers; use Koha::Email; use Koha::Notice::Messages; use Koha::Notice::Templates; +use Koha::Notice::Util; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Auth::TwoFactorAuth; use Koha::Patrons; @@ -65,6 +66,8 @@ BEGIN { ); } +our $domain_limits = {}; + =head1 NAME C4::Letters - Give functions for Letters management @@ -984,6 +987,7 @@ sub SendQueuedMessages { 'where' => $params->{'where'} // q{}, }; my $unsent_messages = _get_unsent_messages( $which_unsent_messages ); + $domain_limits = Koha::Notice::Util->load_domain_limits; # (re)initialize per run MESSAGE: foreach my $message ( @$unsent_messages ) { my $message_object = Koha::Notice::Messages->find( $message->{message_id} ); # If this fails the database is unwritable and we won't manage to send a message that continues to be marked 'pending' @@ -1332,6 +1336,9 @@ sub _send_message_by_email { } } + # Skip this message if we exceed domain limits in this run + return if Koha::Notice::Util->exceeds_limit( $to_address, $domain_limits ); + my $subject = $message->{'subject'}; my $content = $message->{'content'}; -- 2.30.2