diff --git a/app/services/twilio/send_on_twilio_service.rb b/app/services/twilio/send_on_twilio_service.rb index 1133bbf70..c722bd6bf 100644 --- a/app/services/twilio/send_on_twilio_service.rb +++ b/app/services/twilio/send_on_twilio_service.rb @@ -9,9 +9,9 @@ class Twilio::SendOnTwilioService < Base::SendOnChannelService begin twilio_message = client.messages.create(**message_params) rescue Twilio::REST::TwilioError => e - Rails.logger.info "Twilio Error: #{e.message}" + Sentry.capture_exception(e) end - message.update!(source_id: twilio_message.sid) + message.update!(source_id: twilio_message.sid) if twilio_message end def message_params diff --git a/spec/services/twilio/send_on_twilio_service_spec.rb b/spec/services/twilio/send_on_twilio_service_spec.rb index 9fc6e2d57..d4fc16048 100644 --- a/spec/services/twilio/send_on_twilio_service_spec.rb +++ b/spec/services/twilio/send_on_twilio_service_spec.rb @@ -28,6 +28,7 @@ describe Twilio::SendOnTwilioService do message = create(:message, message_type: 'outgoing', private: true, inbox: twilio_inbox, account: account) ::Twilio::SendOnTwilioService.new(message: message).perform expect(twilio_client).not_to have_received(:messages) + expect(message.reload.source_id).to be_nil end it 'if inbox channel is not twilio' do @@ -40,6 +41,7 @@ describe Twilio::SendOnTwilioService do message = create(:message, message_type: 'incoming', inbox: twilio_inbox, account: account) ::Twilio::SendOnTwilioService.new(message: message).perform expect(twilio_client).not_to have_received(:messages) + expect(message.reload.source_id).to be_nil end it 'if message has an source id' do