Class: Twilio::Rails::SMS::UpdateMessageOperation

Inherits:
ApplicationOperation show all
Defined in:
app/operations/twilio/rails/sms/update_message_operation.rb

Overview

Called by Twilio::Rails::SMSController with the Twilio params to update an existing SMS message with any status changes or updates that Twilio sends. The save will only happen if there has been a change.

Instance Method Summary collapse

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/operations/twilio/rails/sms/update_message_operation.rb', line 11

def execute
  message = ::Twilio::Rails.config.message_class.find(message_id)

  if params["MessageStatus"].present?
    message.status = params["MessageStatus"]
  end

  if message.changed?
    message.save!
  end

  message
end