Bugzilla – Attachment 70436 Details for
Bug 19955
Add ability to process only one 'type' of message ( sms, email, etc ) for a given run of process_message_queue.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19955 - Add ability to process only one 'type' of message ( sms, email, etc ) for a given run of process_message_queue.pl
Bug-19955---Add-ability-to-process-only-one-type-o.patch (text/plain), 4.38 KB, created by
Kyle M Hall (khall)
on 2018-01-11 18:31:11 UTC
(
hide
)
Description:
Bug 19955 - Add ability to process only one 'type' of message ( sms, email, etc ) for a given run of process_message_queue.pl
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-01-11 18:31:11 UTC
Size:
4.38 KB
patch
obsolete
>From 487a62d3e712618334b090e9fcd9a18942c5a01d Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Thu, 11 Jan 2018 13:00:31 -0500 >Subject: [PATCH] Bug 19955 - Add ability to process only one 'type' of message > ( sms, email, etc ) for a given run of process_message_queue.pl > >It would be nice to allow emails to be sent overnight, but limit the sending of SMS messages to hours when people are awake. Adding a type limit to process_message_queue.pl would allow this to be accomplished easily. >--- > C4/Letters.pm | 8 ++++++-- > misc/cronjobs/process_message_queue.pl | 5 ++++- > t/db_dependent/Letters.t | 6 ++++-- > 3 files changed, 14 insertions(+), 5 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 42893f1..37802c3 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1023,7 +1023,7 @@ ENDSQL > > =head2 SendQueuedMessages ([$hashref]) > >- my $sent = SendQueuedMessages({ verbose => 1, limit => 50 }); >+ my $sent = SendQueuedMessages({ verbose => 1, limit => 50, type => 'sms' }); > > Sends all of the 'pending' items in the message queue, unless the optional > limit parameter is passed too. The verbose parameter is also optional. >@@ -1035,7 +1035,7 @@ Returns number of messages sent. > sub SendQueuedMessages { > my $params = shift; > >- my $unsent_messages = _get_unsent_messages( { limit => $params->{limit} } ); >+ my $unsent_messages = _get_unsent_messages( { limit => $params->{limit}, type => $params->{type} } ); > MESSAGE: foreach my $message ( @$unsent_messages ) { > # warn Data::Dumper->Dump( [ $message ], [ 'message' ] ); > warn sprintf( 'sending %s message to patron: %s', >@@ -1286,6 +1286,10 @@ sub _get_unsent_messages { > $statement .= ' AND borrowernumber = ? '; > push @query_params, $params->{'borrowernumber'}; > } >+ if ( $params->{'type'} ) { >+ $statement .= ' AND message_transport_type = ? '; >+ push @query_params, $params->{'type'}; >+ } > if ( $params->{'limit'} ) { > $statement .= ' limit ? '; > push @query_params, $params->{'limit'}; >diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl >index adb11bd..93f5c35 100755 >--- a/misc/cronjobs/process_message_queue.pl >+++ b/misc/cronjobs/process_message_queue.pl >@@ -35,6 +35,7 @@ my $limit = undef; > my $method = 'LOGIN'; > my $help = 0; > my $verbose = 0; >+my $type = q{}; > > GetOptions( > 'u|username:s' => \$username, >@@ -43,6 +44,7 @@ GetOptions( > 'm|method:s' => \$method, > 'h|help|?' => \$help, > 'v|verbose' => \$verbose, >+ 't|type' => \$type, > ); > my $usage = << 'ENDUSAGE'; > >@@ -55,11 +57,11 @@ advance_notices.pl script. > This script has the following parameters : > -u --username: username of mail account > -p --password: password of mail account >+ -t --type: If supplied, only processes this type of message ( email, sms ) > -l --limit: The maximum number of messages to process for this run > -m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.) > -h --help: this message > -v --verbose: provides verbose output to STDOUT >- > ENDUSAGE > > die $usage if $help; >@@ -73,6 +75,7 @@ C4::Letters::SendQueuedMessages( > password => $password, > method => $method, > limit => $limit, >+ type => $type, > } > ); > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index e20cefb..f189e19 100644 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 77; >+use Test::More tests => 78; > use Test::MockModule; > use Test::Warn; > >@@ -133,7 +133,9 @@ is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pendin > > > # SendQueuedMessages >-my $messages_processed = C4::Letters::SendQueuedMessages(); >+my $messages_processed = C4::Letters::SendQueuedMessages( { type => 'email' }); >+is($messages_processed, 0, 'No queued messaged process if type limit passed with unused type'); >+$messages_processed = C4::Letters::SendQueuedMessages( { type => 'sms' }); > is($messages_processed, 1, 'all queued messages processed'); > $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); > is( >-- >2.10.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 19955
:
70434
|
70436
|
70437
|
70781
|
70782
|
72588
|
72589
|
73132
|
73133