Bugzilla – Attachment 150777 Details for
Bug 33690
Add ability to send welcome notice when creating patrons using the REST API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33690: Add ability to send welcome notice when creating patrons using the REST API
Bug-33690-Add-ability-to-send-welcome-notice-when-.patch (text/plain), 3.07 KB, created by
Kyle M Hall (khall)
on 2023-05-05 16:27:14 UTC
(
hide
)
Description:
Bug 33690: Add ability to send welcome notice when creating patrons using the REST API
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-05-05 16:27:14 UTC
Size:
3.07 KB
patch
obsolete
>From 5e667bc97dfe8c1c15d9422a489523ba395f5351 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 5 May 2023 12:22:53 -0400 >Subject: [PATCH] Bug 33690: Add ability to send welcome notice when creating > patrons using the REST API > >It would be nice to have the ability to send a welcome notice when creating patrons via the API. > >Test Plan: >1) Apply this patch >2) Ensure you have a WELCOME notice >3) Create a new patron using the REST API ( api/v1/patrons ) >4) Note no welcome notice is sent to the patron ( you can check the > notices tab for the patron ) >5) Repeat step 3, but send the header X-Koha-SendWelcomeEmail with a > value of 1 as part of the POST >6) Note the welcome message for the patron is in their notices! >--- > Koha/REST/V1/Patrons.pm | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index 1852d7ccd2..843065f3e0 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -22,6 +22,7 @@ use Mojo::Base 'Mojolicious::Controller'; > use Koha::Database; > use Koha::Exceptions; > use Koha::Patrons; >+use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); > > use List::MoreUtils qw(any); > use Scalar::Util qw( blessed ); >@@ -113,6 +114,38 @@ sub add { > my $extended_attributes = delete $body->{extended_attributes} // []; > > my $patron = Koha::Patron->new_from_api($body)->store; >+ >+ if ( $c->req->headers->header('X-Koha-SendWelcomeEmail') ) { >+ >+ # if we manage to find a valid email address, send notice >+ if ( $patron->notice_email_address ) { >+ my $letter = GetPreparedLetter( >+ module => 'members', >+ letter_code => 'WELCOME', >+ branchcode => $patron->branchcode, >+ , >+ lang => $patron->lang || 'default', >+ tables => { >+ 'branches' => $patron->branchcode, >+ 'borrowers' => $patron->borrowernumber, >+ }, >+ want_librarian => 1, >+ ); >+ >+ if ($letter) { >+ my $message_id = EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron->id, >+ to_address => $patron->notice_email_address, >+ message_transport_type => 'email' >+ } >+ ); >+ SendQueuedMessages( { message_id => $message_id } ); >+ } >+ } >+ } >+ > $patron->extended_attributes( > [ > map { { code => $_->{type}, attribute => $_->{value} } } >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33690
:
150777
|
150787
|
150791
|
152642
|
155396
|
155397
|
155398
|
155406
|
155407
|
156544
|
156545
|
156546