From fe7df0d3c11cfefa7f90a4dd2bdfa093ca9173a3 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 31 Oct 2024 16:11:59 +0000 Subject: [PATCH] Bug 30300: (QA follow-up) Move logic to queue_notice Signed-off-by: Nick Clemens --- Koha/Patron.pm | 3 ++- misc/cronjobs/membership_expiry.pl | 25 +++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index f97e104e216..1cd2534c8a2 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -2640,7 +2640,8 @@ sub queue_notice { message_name => $params->{message_name} } ); @message_transports = ( keys %{ $messaging_prefs->{transports} } ); - $letter_code = $messaging_prefs->{transports}->{$message_transports[0]} unless $letter_code; + $letter_code = $messaging_prefs->{transports}->{ $message_transports[0] } unless $letter_code; + return if ( $params->{message_name} eq 'Patron_Expiry' && !$messaging_prefs ); } else { @message_transports = @{$params->{message_transports}}; } diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl index d2cd0a6595d..50e213d9620 100755 --- a/misc/cronjobs/membership_expiry.pl +++ b/misc/cronjobs/membership_expiry.pl @@ -262,40 +262,29 @@ while ( my $expiring_patron = $upcoming_mem_expires->next ) { next; } - my $messaging_prefs = C4::Members::Messaging::GetMessagingPreferences( - { - borrowernumber => $expiring_patron->borrowernumber, - message_name => "Patron_Expiry", - } - ); - my @message_transports = ( keys %{ $messaging_prefs->{transports} } ); - my $letter_code = $messaging_prefs->{letter_code}; - - # Skip this patron if they don't want a notification email for card expiry - next if !$messaging_prefs; - my $which_notice; if ($renew) { $expiring_patron->renew_account; $which_notice = $letter_renew; $count_renewed++; } else { - $which_notice = $letter_code || $letter_expiry; + $which_notice = $letter_expiry; } my $from_address = $expiring_patron->library->from_email_address; my $letter_params = { - module => 'members', - letter_code => $which_notice, - branchcode => $expiring_patron->branchcode, - lang => $expiring_patron->lang, + module => 'members', + letter_code => $which_notice, + branchcode => $expiring_patron->branchcode, + lang => $expiring_patron->lang, borrowernumber => $expiring_patron->borrowernumber, - tables => { + tables => { borrowers => $expiring_patron->borrowernumber, branches => $expiring_patron->branchcode, }, }; + my $sending_params = { letter_params => $letter_params, message_name => 'Patron_Expiry', -- 2.39.5