Skip to content

Commit

Permalink
don't assume ENV['DOMAIN'] exists
Browse files Browse the repository at this point in the history
  • Loading branch information
albertsun committed Apr 11, 2016
1 parent 8a51920 commit 0a12b86
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/models/agents/twilio_receive_text_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TwilioReceiveTextAgent < Agent
In order to create events with this agent, configure Twilio to send POST requests to:
```
#{interpolated['server_url'] || 'https://'+ENV['DOMAIN']}/users/#{user.id}/web_requests/#{id || ':id'}/sms-endpoint
#{post_url}
```
#{'The placeholder symbols above will be replaced by their values once the agent is saved.' unless id}
Expand All @@ -35,7 +35,7 @@ def default_options
{
'account_sid' => 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'auth_token' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'server_url' => ENV['DOMAIN'],
'server_url' => "https://#{ENV['DOMAIN'].presence || example.com}",
'reply_text' => '',
"expected_receive_period_in_days" => 1
}
Expand All @@ -52,7 +52,11 @@ def working?
end

def post_url
"#{interpolated['server_url']}/users/#{user.id}/web_requests/#{id}/sms-endpoint"
if interpolated['server_url'].present?
"#{interpolated['server_url']}/users/#{user.id}/web_requests/#{id || ':id'}/sms-endpoint"
else
"https://#{ENV['DOMAIN']}/users/#{user.id}/web_requests/#{id || ':id'}/sms-endpoint"
end
end

def receive_web_request(params, method, format, headers={}, request=nil)
Expand Down

0 comments on commit 0a12b86

Please sign in to comment.