Bug 39408: Don't attempt to send a message if one is not generated

The routine to create the message can return nothing if there is no content,
we should handle this case and not attempt to send.

To test:
1 - Test plan from last patch
2 - Apply this patch
3 - POST to patron API again
4 - Success!

Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c1fa513be9)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Nick Clemens 2025-03-21 13:58:24 +00:00 committed by Paul Derscheid
parent 7036902f57
commit 91da4b4b38
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 5 additions and 4 deletions

View File

@ -121,9 +121,8 @@ sub add {
module => 'members',
letter_code => 'WELCOME',
branchcode => $patron->branchcode,
,
lang => $patron->lang || 'default',
tables => {
lang => $patron->lang || 'default',
tables => {
'branches' => $patron->branchcode,
'borrowers' => $patron->borrowernumber,
},
@ -139,7 +138,9 @@ sub add {
message_transport_type => 'email'
}
);
SendQueuedMessages( { message_id => $message_id } );
# Don't send a message if we didn't generate one for some reason
SendQueuedMessages( { message_id => $message_id } ) if $message_id;
}
}
}