From 48816070767f8bda28673518d4cb4023806460f2 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 25 Feb 2022 20:04:41 +0000 Subject: [PATCH] Bug 22993: Handle default messaging preferences during patron creation from API TO test: 1 - Set default messaging preferences for a patron category 2 - Create a patron in that category using the API 3 - Verify messaging preferences are not set 4 - Apply patch, restart all 5 - Create another patron 6 - Verify messaging preferences are correctly set 7 - prove -v t/db_dependent/api/v1/patrons.t Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi Signed-off-by: Fridolin Somers (cherry picked from commit 1e02087923230e5c6ecad66dcf1288a196ba2c81) Signed-off-by: Andrew Fuerste-Henry (cherry picked from commit ced32711bb2915e9b4dd97bf3695d86712620ca4) Signed-off-by: Victor Grousset/tuxayo --- Koha/REST/V1/Patrons.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm index abefe227a5..8f719bc3a8 100644 --- a/Koha/REST/V1/Patrons.pm +++ b/Koha/REST/V1/Patrons.pm @@ -136,6 +136,15 @@ sub add { my $patron = Koha::Patron->new_from_api( $c->validation->param('body') )->store; + if ( C4::Context->preference('EnhancedMessagingPreferences') ) { + C4::Members::Messaging::SetMessagingPreferencesFromDefaults( + { + borrowernumber => $patron->borrowernumber, + categorycode => $patron->categorycode, + } + ); + } + $c->res->headers->location( $c->req->url->to_string . '/' . $patron->borrowernumber ); return $c->render( status => 201, -- 2.39.5