Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ GEM
eventmachine
json
net-http-persistent
puma (2.9.1)
puma (2.3.2)
rack (>= 1.1, < 2.0)
quiet_assets (1.0.3)
railties (>= 3.1, < 5.0)
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: env ENABLE_DJ_WORKER=true bundle exec puma -p $PORT -e $RAILS_ENV -t 0:8
web: bundle exec puma -C config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ class Incidents::Api::ResponderMessagesTwilioController < ApplicationController
protect_from_forgery with: :null_session

def incoming
p "INCOMING"
body = params[:Body]
person = find_person_by_phone params[:From]

if params[:NumMedia] && (media_count = params[:NumMedia].to_i) > 0
media_urls = []
media = media_count.times.map do |i|
{content_type: params["MediaContentType#{i}"],
url: params["MediaUrl#{i}"]}
media_urls << params["MediaUrl#{i}"]
end

body += " [The message had #{media_count} #{media_count == 1 ? 'attachment' : 'attachments'}]"
media_urls = media_urls.join(", ");
body += " [The message has #{media_count} #{media_count == 1 ? 'attachment' : 'attachments'}. They can be found at #{media_urls}]"
else
media = []
end
Expand Down Expand Up @@ -59,6 +62,7 @@ def find_person_by_phone phone
end

def chapter
p "CHAPTER"
@chapter ||= Roster::Chapter.with_twilio_account_sid_value(params[:AccountSid])
.with_incidents_twilio_number_value(params[:To]).first!
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ def all_recipients
helper_method :all_recipients

def send_message resource
p "MESSAGE"
message = resource.build_outbound_message message: recruitment_message, chapter: incident.chapter

client = Incidents::SMSClient.new(incident.chapter)
client.send_message(message)
end

def recruitment_message
p "Recruitment MESSAGE"
"DCSOps Incident Recruitment: #{parent.recruitment_message} - Reply with yes or no."
end

Expand Down
5 changes: 4 additions & 1 deletion app/controllers/incidents/responders_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Incidents::RespondersController < Incidents::BaseController
class Incidents::RespondersController < Incidents::BaseController
inherit_resources
respond_to :html, :json, :js
belongs_to :chapter, finder: :find_by_url_slug!, parent_class: Roster::Chapter do
Expand Down Expand Up @@ -56,6 +56,7 @@ def valid_partial? partial
protected

def notify_assignment
p "NOTIFY"
Incidents::UpdatePublisher.new(parent.chapter, parent).publish_responders
return unless resource.was_available

Expand All @@ -69,6 +70,8 @@ def send_assignment_email
end

def send_assignment_sms
p "SMS CLIENT"
p sms_client
message = build_assignment_sms_message
sms_client.send_message(message)
flash[:notice] = 'Sent assignment SMS.'
Expand Down
3 changes: 2 additions & 1 deletion config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
Scheduler::Application.config.secret_key_base = Rails.env.production? ? ENV['RAILS_SECRET_KEY'] : '8f2bbc36c698298224963ef68cec4a731c9408f438ff86a55f0d649aaa965e29363d03a97c1d4ac098f2ddf261b4db36ba36d3457f29c20217fc688278f35e48'
Scheduler::Application.config.secret_key_base = '8f2bbc36c698298224963ef68cec4a731c9408f438ff86a55f0d649aaa965e29363d03a97c1d4ac098f2ddf261b4db36ba36d3457f29c20217fc688278f35e48'

15 changes: 15 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
2 changes: 2 additions & 0 deletions config/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
production:
secret_key_base: 8f2bbc36c698298224963ef68cec4a731c9408f438ff86a55f0d649aaa965e29363d03a97c1d4ac098f2ddf261b4db36ba36d3457f29c20217fc688278f35e48
1 change: 1 addition & 0 deletions db/migrate/20130419235200_create_roster_chapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def change
t.string :code
t.string :short_name
t.string :time_zone_raw
t.string :password

t.timestamps
end
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
admin.password = 'test123'
admin.save!
# Create an example non-admin user. Change the credentials here as desired.
Roster::Person.create(chapter: Roster::Chapter.first, email: "example@example.com", username: "example_user", password: "password", last_name: "Example_User", first_name: 'TestUser', vc_is_active: 1)
Roster::Person.create(chapter: Roster::Chapter.first, email: "example@example.com", username: "arieldiamond", password: "password", last_name: "Example_User", first_name: 'TestUser', vc_is_active: 1)
example = Roster::Person.find_by_last_name 'Example_User'
example.password = 'test123'
example.save!
Expand Down
7 changes: 6 additions & 1 deletion lib/incidents/sms_client.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
class Incidents::SMSClient
def initialize(chapter)
p "CHAPTER INITIALIZE"
@chapter = chapter
end

def send_message(responder_message)
p "RESPONDER MESSAGE"
p responder_message
return unless have_credentials?

responder_message.direction = 'outgoing'
Expand All @@ -13,7 +16,8 @@ def send_message(responder_message)
client.account.messages.create(
:from => from_phone_number,
:to => responder_message.remote_number,
:body => responder_message.message
:body => responder_message.message,
:mediaUrl => responder_message.mediaUrl
)

responder_message.save validate: false
Expand All @@ -22,6 +26,7 @@ def send_message(responder_message)
protected

def have_credentials?
p "HAVE CREDENTIALS"
@chapter.twilio_account_sid.present? && @chapter.twilio_auth_token.present?
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vc/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class InvalidCredentials < StandardError; end

attr_accessor :cookies
attr_accessor :username, :password
attr_accessible :password
attr_accessor :password
attr_accessor :logger

def initialize(user, pass, logger=Rails.logger)
Expand Down