From 03060ab7d68efe2760a1a7b32124e4d1b0506b16 Mon Sep 17 00:00:00 2001 From: Johanna Raisa Date: Fri, 20 May 2022 10:16:10 +0300 Subject: [PATCH] Bug 31481: pass message_id to SMS drivers This patch adds message_id to _send_message_by_sms and sms_send so the driver could be build to catch SMS gateways delivery report. Test plan: 1) Apply the patch 2) prove t/SMS.t Sponsored-by: Koha-Suomi Oy --- C4/Letters.pm | 1 + C4/SMS.pm | 3 ++- t/SMS.t | 12 +++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 7c136f32f9..468fc8f820 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1519,6 +1519,7 @@ sub _send_message_by_sms { { destination => $patron->smsalertnumber, message => $message->{'content'}, + message_id => $message->{'message_id'}, } ); diff --git a/C4/SMS.pm b/C4/SMS.pm index ce3358f66a..661bb7f566 100644 --- a/C4/SMS.pm +++ b/C4/SMS.pm @@ -74,7 +74,7 @@ sub send_sms { my $self = shift; my $params= shift; - foreach my $required_parameter ( qw( message destination ) ) { + foreach my $required_parameter ( qw( message destination message_id ) ) { # Should I warn in some way? return unless defined $params->{ $required_parameter }; } @@ -120,6 +120,7 @@ sub send_sms { $sent = $sender->send_sms( to => $params->{destination}, text => $params->{message}, + _message_id => $params->{'message_id'}, ); }; diff --git a/t/SMS.t b/t/SMS.t index bf8de65152..8b2cc0c01f 100755 --- a/t/SMS.t +++ b/t/SMS.t @@ -19,7 +19,7 @@ use Modern::Perl; use t::lib::Mocks; -use Test::More tests => 7; +use Test::More tests => 8; BEGIN { use_ok('C4::SMS', qw( driver send_sms )); @@ -38,17 +38,26 @@ is( $send_sms, undef, 'send_sms without arguments returns undef' ); $send_sms = C4::SMS->send_sms({ destination => 'my destination', + message_id => 1, }); is( $send_sms, undef, 'send_sms without message returns undef' ); $send_sms = C4::SMS->send_sms({ message => 'my message', + message_id => 1, }); is( $send_sms, undef, 'send_sms without destination returns undef' ); $send_sms = C4::SMS->send_sms({ destination => 'my destination', message => 'my message', +}); +is( $send_sms, undef, 'send_sms without message_id returns undef' ); + +$send_sms = C4::SMS->send_sms({ + destination => 'my destination', + message => 'my message', + message_id => 1, driver => '', }); is( $send_sms, undef, 'send_sms with an undef driver returns undef' ); @@ -57,6 +66,7 @@ $send_sms = C4::SMS->send_sms({ destination => '+33123456789', message => 'my message', driver => 'Test', + message_id => 1, }); is( $send_sms, 1, 'send_sms returns 1' ); -- 2.34.1