[Bps-public-commit] rt-extension-notifysms branch, master, updated. 9abff28853ad445ec2aa6e9d39ba0cc400a82fa2

Craig Kaiser craig at bestpractical.com
Mon Jun 25 12:00:38 EDT 2018


The branch, master has been updated
       via  9abff28853ad445ec2aa6e9d39ba0cc400a82fa2 (commit)
      from  3d18b752f34a9eda997fa5e0907cabab136e9e35 (commit)

Summary of changes:
 lib/RT/Action/NotifyTwilio.pm | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit 9abff28853ad445ec2aa6e9d39ba0cc400a82fa2
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon Jun 25 11:43:52 2018 -0400

    Update message logged if error from Twilio

diff --git a/lib/RT/Action/NotifyTwilio.pm b/lib/RT/Action/NotifyTwilio.pm
index 7f62978..76dd015 100644
--- a/lib/RT/Action/NotifyTwilio.pm
+++ b/lib/RT/Action/NotifyTwilio.pm
@@ -5,6 +5,7 @@ use base qw(RT::Action::NotifySMS);
 use strict;
 use warnings;
 use LWP::UserAgent;
+use JSON qw(decode_json);
 
 =head2 NotifyTwilio
 
@@ -50,7 +51,7 @@ sub SendMessage {
 
         api_url => 'https://api.twilio.com/2010-04-01/Accounts/'
             . $Credentials{account_id}
-            . '/Messages'
+            . '/Messages.json'
     );
 
     my $ua = LWP::UserAgent->new;
@@ -67,10 +68,12 @@ sub SendMessage {
         );
         my $response = $ua->post( $Twilio{api_url}, \%text_message );
 
-        if ( $response->is_success ) {
-            RT::Logger->debug( 'Sending message to: ' . $to );
-        } else {
-            RT::Logger->error( 'Failed to send message to: ' . $to );
+        if ( $response->is_error ) {
+            my $result = decode_json( $response->content );
+
+            if ( $result->{message} ) {
+                RT::Logger->error( "$result->{message}" );
+            }
         }
     }
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list