DavidLiu 3 months ago
parent
commit
c3e734a29c
1 changed files with 12 additions and 12 deletions
  1. 12 12
      src/core/callcenter/esl/handler/channel_hangup_handler.py

+ 12 - 12
src/core/callcenter/esl/handler/channel_hangup_handler.py

@@ -33,16 +33,8 @@ class ChannelHangupHandler(EslEventHandler):
     def handle(self, address, event, coreUUID):
         # self.logger.info(json.loads(event.serialize('json')))
         try:
-            call_id = EslEventUtil.getCallId(event)
-            device_id = EslEventUtil.getDeviceId(event)
-            self.logger.info('call_id is %s, event=%s', call_id, json.loads(event.serialize('json')) )
-            if not call_id:
-                call_id = self.cache.get_call_id_by_device_id(device_id)
-            if not call_id:
-                other_leg_device_id = event.getHeader("variable_bridge_uuid")
-                call_id = self.cache.get_call_id_by_device_id(other_leg_device_id)
-
-            self.logger.info('call_id is %s', call_id)
+            call_id = self.get_call_id(event)
+            self.logger.info('call_id is %s, event=%s', call_id)
             if not call_id:
                 self.release(event)
                 self.logger.info("call_id is null, event=%s", json.loads(event.serialize('json')))
@@ -56,9 +48,7 @@ class ChannelHangupHandler(EslEventHandler):
                 return
 
             device_id = EslEventUtil.getDeviceId(event)
-            device_id = device_id if device_id else EslEventUtil.getUniqueId(event)
             device_info = call_info.device_info_map.get(device_id)
-            # self.logger.info('device_id is ', device_id)
             if not device_info:
                 self.release(event)
                 self.logger.info("device_info is null, call_id=%s, device_id=%s, call_info=%s", call_id, device_id, call_info)
@@ -147,6 +137,16 @@ class ChannelHangupHandler(EslEventHandler):
         except:
             traceback.print_exc()
 
+    def get_call_id(self, event):
+        call_id = EslEventUtil.getCallId(event)
+        device_id = EslEventUtil.getDeviceId(event)
+        if not call_id:
+            call_id = self.cache.get_call_id_by_device_id(device_id)
+        if not call_id:
+            other_leg_device_id = event.getHeader("variable_bridge_uuid")
+            call_id = self.cache.get_call_id_by_device_id(other_leg_device_id)
+        return call_id
+
     def get_call_info_record(self, call_info):
         records = []
         sip_status = []