Browse Source

Fixes #3247 - CTI-API should handle doubled requests better.

Rolf Schmidt 3 years ago
parent
commit
b3da6d31ff
2 changed files with 18 additions and 4 deletions
  1. 6 4
      app/models/cti/driver/base.rb
  2. 12 0
      spec/requests/integration/cti_spec.rb

+ 6 - 4
app/models/cti/driver/base.rb

@@ -41,12 +41,14 @@ class Cti::Driver::Base
     end
 
     log = Cti::Log.process(@params)
+    if log.present?
 
-    # push new call notification
-    push_incoming_call(log)
+      # push new call notification
+      push_incoming_call(log)
 
-    # open screen if call got answered
-    push_open_ticket_screen(log)
+      # open screen if call got answered
+      push_open_ticket_screen(log)
+    end
 
     result || {}
   end

+ 12 - 0
spec/requests/integration/cti_spec.rb

@@ -407,6 +407,18 @@ RSpec.describe 'Integration CTI', type: :request do
 
       travel 1.second
 
+      # inbound - I - answer for hangup by customer
+      post "/api/v1/cti/#{token}", params: {
+        event:     'answer',
+        direction: 'in',
+        call_id:   '1234567890-3',
+        to:        '4930600000000',
+        from:      '4912347114711',
+      }, as: :json
+      expect(response).to have_http_status(:ok)
+
+      travel 1.second
+
       # inbound - II - new call
       post "/api/v1/cti/#{token}", params: {
         event:     'newCall',