From 383c5b9343f55048774c706609c4d8bc423f0ec4 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 3 Aug 2016 14:31:17 -0400 Subject: [PATCH] Fixups and inline documentation Signed-off-by: Mike Rylander --- Open-ILS/src/extras/ils_events.xml | 3 ++ .../lib/OpenILS/Application/Circ/CircNotify.pm | 52 +++++++++++++++++----- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml index 2ecd618bae..3776c0dbb7 100644 --- a/Open-ILS/src/extras/ils_events.xml +++ b/Open-ILS/src/extras/ils_events.xml @@ -927,6 +927,9 @@ Copy is marked as lost and paid + + Potentially notified patron does not own the circulation. + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircNotify.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircNotify.pm index e8199364d0..c3c5974af6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircNotify.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircNotify.pm @@ -44,19 +44,20 @@ sub circ_batch_notify { my $circs = $e->search_action_circulation({ id => $circlist }); return $e->event if $e->event; + my $hook = 'circ.checkout.batch_notify'; + $hook .= '.session' if $self->api_name =~ /session/; + for my $circ (@$circs) { - return undef if $circ->usr != $patronid; + # WISHLIST: This may become more sophisticated and check "friend" permissions + # in the future, at lease in the non-session variant. + return OpenILS::Event->new('PATRON_CIRC_MISMATCH') if $circ->usr != $patronid; return $e->event unless $e->allowed('VIEW_CIRCULATIONS', $circ->circ_lib); } - my $hook = 'circ.checkout.batch_notify'; - $hook .= '.session' if $self->api_name =~ /session/; - - my %events; my $multi = OpenSRF::MultiSession->new( app => 'open-ils.trigger', - cap => 3, # + cap => 3, success_handler => sub { my $self = shift; my $req = shift; @@ -80,10 +81,14 @@ sub circ_batch_notify { $multi->session_wait(1); $client->status( new OpenSRF::DomainObject::oilsContinueStatus ); + if (!keys(%events)) { + return $client->respond_complete; + } + my @out; $multi = OpenSRF::MultiSession->new( app => 'open-ils.trigger', - cap => 3, # + cap => 3, success_handler => sub { my $self = shift; my $req = shift; @@ -97,15 +102,42 @@ sub circ_batch_notify { ) for ( sort keys %events ); $multi->session_wait(1); - $client->respond_complete; + return $client->respond_complete; } __PACKAGE__->register_method( - method => 'circ_batch_notify', + method => 'circ_batch_notify', api_name => 'open-ils.circ.checkout.batch_notify', + stream => 1, + signature => { + desc => 'Creates and fires grouped events for a set of circulation IDs', + params => [ + { name => 'authtoken', desc => 'Staff auth token', type => 'string' }, + { name => 'patronid', desc => 'actor.usr.id of patron which must own the circulations', type => 'number' } + { name => 'circlist', desc => 'Arrayref of circulation IDs to bundle into the event group', type => 'array' } + ], + return => { + desc => 'Event on error, stream of zero or more event group firing results '. + 'otherwise. See: open-ils.trigger.event_group.fire' + } + } ); __PACKAGE__->register_method( - method => 'circ_batch_notify', + method => 'circ_batch_notify', api_name => 'open-ils.circ.checkout.batch_notify.session', + stream => 1, + signature => { + desc => 'Creates and fires grouped events for a set of circulation IDs. '. + 'For use by session-specific actions such as self-checkout or circ desk checkout.', + params => [ + { name => 'authtoken', desc => 'Staff auth token', type => 'string' }, + { name => 'patronid', desc => 'actor.usr.id of patron which must own the circulations', type => 'number' } + { name => 'circlist', desc => 'Arrayref of circulation IDs to bundle into the event group', type => 'array' } + ], + return => { + desc => 'Event on error, stream of zero or more event group firing results '. + 'otherwise. See: open-ils.trigger.event_group.fire' + } + } ); 1; -- 2.11.0