From 4e6938afc27ac37a0b222a5233f2c2753207b15f Mon Sep 17 00:00:00 2001 From: Benjamin Aronov Date: Sun, 27 Apr 2025 21:25:15 +0300 Subject: [PATCH 1/4] Remove credentials.yml.enc from repository --- config/credentials.yml.enc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 config/credentials.yml.enc diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc deleted file mode 100644 index a87a2a8..0000000 --- a/config/credentials.yml.enc +++ /dev/null @@ -1 +0,0 @@ -2lcax3RF4GiKVDTOz34V7q8g1LVIHIVnB/iJJ22nCdQ5ufXCkObPpmoeRjwuS2gjf/AXSCGI2jJBIsRevsrhinIr+Cxv3IIuDAzpJ9ccFefHCwh7/xivb5vkR9M9B7uBTJDZEUua/Klsta3gdWuMhDmFWS2vVnaYQagsc22AZ7SuCBMBL613PwU3ayHl7kru1Ul0vKKVFmnkMXWWtnDkQjmjNjU8r76qqbKnj8qXlqQYgTlXASAlEtO+NofgRvkCBJ4epSdxZ1QZpYB5xkdTovi6/SOYJJHRXPUJLkJNWCqwMBxQnKYZpdZ+T/Zi/hyiwsxawI+vMOO3lRYR+qCs3NcF49GNOyiy7nL2OBDO1e1R6jNal0t6c5rimcEpRoV1DB7rbbPjWIx30ZGXyRy5ksfcBthuQx9x6PzayWU1lMdN/msh2eKskBBNxOg3WchHfwrxs8Pmb7LWEeeb+xu4eC9vU8Q7Of4HQ6DwS0SmaajQnuWCSGc6EOy1--om7fEulVdYgAjk2F--HvQtviBJk3FU1Ozc4qbONQ== \ No newline at end of file From ccfc8af025f18334e4941f064eaf78775d6b5523 Mon Sep 17 00:00:00 2001 From: Benjamin Aronov Date: Sun, 27 Apr 2025 22:25:34 +0300 Subject: [PATCH 2/4] Added Voice Call Events Functionality --- app/controllers/call_events_controller.rb | 18 ++++++++++++++++++ app/helpers/call_events_helper.rb | 2 ++ app/views/call_events/create.html.erb | 2 ++ config/credentials.yml.enc | 1 + config/routes.rb | 2 ++ .../controllers/call_events_controller_test.rb | 8 ++++++++ 6 files changed, 33 insertions(+) create mode 100644 app/controllers/call_events_controller.rb create mode 100644 app/helpers/call_events_helper.rb create mode 100644 app/views/call_events/create.html.erb create mode 100644 config/credentials.yml.enc create mode 100644 test/controllers/call_events_controller_test.rb diff --git a/app/controllers/call_events_controller.rb b/app/controllers/call_events_controller.rb new file mode 100644 index 0000000..3da60fe --- /dev/null +++ b/app/controllers/call_events_controller.rb @@ -0,0 +1,18 @@ +# app/controllers/call_events_controller.rb +class CallEventsController < ApplicationController + # We disable CSRF for this webhook call + skip_before_action :verify_authenticity_token + + def create + if params[:uuid] + Call.where(uuid: params[:uuid]) + .first_or_create + .update( + status: params[:status], + conversation_uuid: params[:conversation_uuid] + ) + end + + head :ok + end +end diff --git a/app/helpers/call_events_helper.rb b/app/helpers/call_events_helper.rb new file mode 100644 index 0000000..abb67a4 --- /dev/null +++ b/app/helpers/call_events_helper.rb @@ -0,0 +1,2 @@ +module CallEventsHelper +end diff --git a/app/views/call_events/create.html.erb b/app/views/call_events/create.html.erb new file mode 100644 index 0000000..ed888e9 --- /dev/null +++ b/app/views/call_events/create.html.erb @@ -0,0 +1,2 @@ +

CallEvents#create

+

Find me in app/views/call_events/create.html.erb

diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000..c254bbe --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +ZpVxnnWvtlkJqhBwrWVi8PMvzvT7/BY+yQh9VJJo6ysrgYmcWuyI3UPKrbCy6sfxCBtdgO7IKFrkTxRpyHedR0i4MDwGgUFJTK8ez6iXtoM4dBnf23usoFvAEuogM1+AAeyqBMAJUdtghY08u8/r5UtNmxgtapJp+Oc3DIiPnYtgvgJ2xFwInuk/VZqFnrHyQOKfqzJ7DGCsPJOuWJqauf6a9BJx67k6hrxzDRze2ybySL1rn/gkfpltkCIPYjebMriDZBi8Wa8Em1/LwvzO9JwadFaPwagrK3d3TCMKsyWsiup8gGOLxABpsTmzLvw2zzeRBEo5SxKiVCabRgBdHrGfTNiFOKjWNzBmLZXT9eJ03Wnakbe3z40h8Y/jDyIJ3PEGOzdQOlG7YtH6JNqyWvfa8AUOgjW8P90uRJr7RwkAC+UgFCgWnuih0JEyRRCybkHOHwu1/dmE2z65GADRbzUyAQfOygR8KCEAk1UW0s3V3TeLOA72amiY--oHceahh7YS8vvw8m--Vfr3zSnGh6xNf+gYox+lzw== \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d08d6a6..2a5e851 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,4 +12,6 @@ # For OutboundCall controller, new & create & show resources :outbound_calls, only: [:new, :create, :show] + resources :call_events, only: [:create] + resources :inbound_calls, only: [:create] end diff --git a/test/controllers/call_events_controller_test.rb b/test/controllers/call_events_controller_test.rb new file mode 100644 index 0000000..c8650d1 --- /dev/null +++ b/test/controllers/call_events_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class CallEventsControllerTest < ActionDispatch::IntegrationTest + test "should get create" do + get call_events_create_url + assert_response :success + end +end From 5ebf5218bb172f229306fe66ebc67e6b07e3418a Mon Sep 17 00:00:00 2001 From: Benjamin Aronov Date: Sun, 27 Apr 2025 22:38:10 +0300 Subject: [PATCH 3/4] Added Inbound Call Functionality --- app/controllers/inbound_calls_controller.rb | 26 +++++++++++++++++++ app/helpers/inbound_calls_helper.rb | 2 ++ app/views/inbound_calls/create.html.erb | 2 ++ config/routes.rb | 1 + .../inbound_calls_controller_test.rb | 8 ++++++ 5 files changed, 39 insertions(+) create mode 100644 app/controllers/inbound_calls_controller.rb create mode 100644 app/helpers/inbound_calls_helper.rb create mode 100644 app/views/inbound_calls/create.html.erb create mode 100644 test/controllers/inbound_calls_controller_test.rb diff --git a/app/controllers/inbound_calls_controller.rb b/app/controllers/inbound_calls_controller.rb new file mode 100644 index 0000000..57bf990 --- /dev/null +++ b/app/controllers/inbound_calls_controller.rb @@ -0,0 +1,26 @@ +# app/controllers/inbound_calls_controller.rb +class InboundCallsController < ApplicationController + # We disable CSRF for this webhook call + skip_before_action :verify_authenticity_token + + def create + Call.where(conversation_uuid: params[:conversation_uuid]) + .first_or_create + .update( + to: params[:to], + from: params[:from], + uuid: params[:uuid], + conversation_uuid: params[:conversation_uuid], + is_inbound: true + + ) + + render json: [ + { + action: 'talk', + voiceName: 'Jennifer', + text: 'Hello, thank you for calling. This is Jennifer from Vonage. Ciao.' + } + ] + end +end diff --git a/app/helpers/inbound_calls_helper.rb b/app/helpers/inbound_calls_helper.rb new file mode 100644 index 0000000..eec487b --- /dev/null +++ b/app/helpers/inbound_calls_helper.rb @@ -0,0 +1,2 @@ +module InboundCallsHelper +end diff --git a/app/views/inbound_calls/create.html.erb b/app/views/inbound_calls/create.html.erb new file mode 100644 index 0000000..add3318 --- /dev/null +++ b/app/views/inbound_calls/create.html.erb @@ -0,0 +1,2 @@ +

InboundCalls#create

+

Find me in app/views/inbound_calls/create.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 2a5e851..9d7c12e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + get "inbound_calls/create" # For OutboundSms controller, new & create get '/outbound_sms/new', to: 'outbound_sms#new', as: :new_outbound_sms diff --git a/test/controllers/inbound_calls_controller_test.rb b/test/controllers/inbound_calls_controller_test.rb new file mode 100644 index 0000000..cd3bf24 --- /dev/null +++ b/test/controllers/inbound_calls_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class InboundCallsControllerTest < ActionDispatch::IntegrationTest + test "should get create" do + get inbound_calls_create_url + assert_response :success + end +end From 05a682c61503397a3964758c6e15291216a6d971 Mon Sep 17 00:00:00 2001 From: Benjamin Aronov Date: Mon, 28 Apr 2025 09:43:40 +0300 Subject: [PATCH 4/4] Removed unnecessary views. --- app/views/call_events/create.html.erb | 2 -- app/views/inbound_calls/create.html.erb | 2 -- app/views/inbound_sms/create.html.erb | 2 -- app/views/sms_message_status/create.html.erb | 2 -- config/routes.rb | 5 ++++- 5 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 app/views/call_events/create.html.erb delete mode 100644 app/views/inbound_calls/create.html.erb delete mode 100644 app/views/inbound_sms/create.html.erb delete mode 100644 app/views/sms_message_status/create.html.erb diff --git a/app/views/call_events/create.html.erb b/app/views/call_events/create.html.erb deleted file mode 100644 index ed888e9..0000000 --- a/app/views/call_events/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

CallEvents#create

-

Find me in app/views/call_events/create.html.erb

diff --git a/app/views/inbound_calls/create.html.erb b/app/views/inbound_calls/create.html.erb deleted file mode 100644 index add3318..0000000 --- a/app/views/inbound_calls/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

InboundCalls#create

-

Find me in app/views/inbound_calls/create.html.erb

diff --git a/app/views/inbound_sms/create.html.erb b/app/views/inbound_sms/create.html.erb deleted file mode 100644 index d3447c9..0000000 --- a/app/views/inbound_sms/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

InboundSms#create

-

Find me in app/views/inbound_sms/create.html.erb

diff --git a/app/views/sms_message_status/create.html.erb b/app/views/sms_message_status/create.html.erb deleted file mode 100644 index f164d85..0000000 --- a/app/views/sms_message_status/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

SmsMessageStatus#create

-

Find me in app/views/sms_message_status/create.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 9d7c12e..bdafae7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ Rails.application.routes.draw do - get "inbound_calls/create" # For OutboundSms controller, new & create get '/outbound_sms/new', to: 'outbound_sms#new', as: :new_outbound_sms @@ -13,6 +12,10 @@ # For OutboundCall controller, new & create & show resources :outbound_calls, only: [:new, :create, :show] + + # For CallEvents controller, create resources :call_events, only: [:create] + + # For InboundCalls controller, create resources :inbound_calls, only: [:create] end