774056846 4 months ago
parent
commit
e40d1d2e08
1 changed files with 21 additions and 4 deletions
  1. 21 4
      src/core/callcenter/esl/utils/esl_event_util.py

+ 21 - 4
src/core/callcenter/esl/utils/esl_event_util.py

@@ -2,6 +2,7 @@
 # encoding:utf-8
 
 import random
+import re
 import string
 
 CORE_UUID = "Core-UUID"
@@ -58,7 +59,6 @@ CALLER_CHANNEL_HOLD_ACCUM = "Caller-Channel-Hold-Accum"
 CALLER_CHANNEL_LAST_HOLD = "Caller-Channel-Last-Hold"
 CALLER_CHANNEL_TRANSFER_TIME = "Caller-Channel-Transfer-Time"
 CALLER_CHANNEL_RESURRECT_TIME = "Caller-Channel-Resurrect-Time"
-
 CALL_HANGUP_CAUSE = "Hangup-Cause"
 
 VARIABLE_SIP_TO_URI = "variable_sip_to_uri"
@@ -71,6 +71,7 @@ VARIABLE_RTP_USE_CODEC = "variable_rtp_use_codec_name"
 VARIABLE_SIP_TERM_STATUS = "variable_sip_term_status"
 VARIABLE_LOCAL_MEDIA_IP = "variable_local_media_ip"
 VARIABLE_SIP_FROM_USER = "variable_sip_from_user"
+VARIABLE_APPLICATION_DATA = "variable_current_application_data"
 
 VARIABLE_SIP_LIBRA_CALLID = "variable_sip_h_P-LIBRA-CallId"
 VARIABLE_SIP_LIBRA_IS_LAST_CALL = "variable_sip_h_P-LIBRA-IsLastCall"
@@ -98,6 +99,7 @@ VARIABLE_SIP_H_X_CALL_SEQUENCE_ID = "variable_sip_h_X-callSequenceId"
 SIP_H_P_LIBRA_CALL_SEQUENCE_ID = "sip_h_P-LIBRA-callSequenceId"
 VARIABLE_SIP_H_P_LIBRA_CALL_SEQUENCE_ID = "variable_sip_h_P-LIBRA-callSequenceId"
 SIP_H_P_LIBRA_CALL_ID = "sip_h_P-LIBRA-CallId"
+SIP_H_P_LIBRA_DeviceId = "sip_h_P-LIBRA-DeviceId"
 VARIABLE_SIP_H_P_LIBRA_CTI_FLOW_ID = "variable_sip_h_P-LIBRA-CtiFlowId"
 VARIABLE_SIP_H_P_LIBRA_NEED_HOLD_MUSIC = "variable_sip_h_P-LIBRA-need-hold-music"
 OTHER_LEG_UNIQUE_ID = "Other-Leg-Unique-ID"
@@ -376,16 +378,31 @@ def getSipFromUser(e):
     return e.getHeader(VARIABLE_SIP_FROM_USER)
 
 
-def getCallId(e):
-    return e.getHeader(VARIABLE_SIP_LIBRA_CALLID)
+def getApplicationData(e):
+    text = e.getHeader(VARIABLE_APPLICATION_DATA)
+    if not text:
+        return {}
+    pattern = r"([a-zA-Z0-9_\-]+)=([A-Za-z0-9]+)"
+    matches = re.findall(pattern, text)
+    variables = {key: value for key, value in matches}
+    return variables
 
 
+def getCallId(e):
+    call_id = e.getHeader(VARIABLE_SIP_LIBRA_CALLID)
+    if not call_id:
+        call_id = getApplicationData(e).get(SIP_H_P_LIBRA_CALL_ID)
+    return call_id
+
 def getOriginationUuid(e):
     return e.getHeader(VARIABLE_ORIGINATION_UUID)
 
 
 def getDeviceId(e):
-    return e.getHeader(VARIABLE_SIP_LIBRA_DEVICE_ID)
+    device_id = e.getHeader(VARIABLE_SIP_LIBRA_DEVICE_ID)
+    if not device_id:
+        device_id = getApplicationData(e).get(SIP_H_P_LIBRA_DeviceId)
+    return device_id
 
 
 def getLIBRAHangupReason(e):