Przeglądaj źródła

Merge branch 'dev_transfer_20241123' of ssh://gitlab.fuxicarbon.com:1111/client_service/voice-gateway-service into dev_transfer_20241123

余尚辉 4 miesięcy temu
rodzic
commit
483433629e

+ 25 - 21
src/core/callcenter/esl/client.py

@@ -231,7 +231,7 @@ class InboundClient:
         """桥接电话"""
         self.multi_set_var(device_id1, BRIDGE_VARIABLES)
         self.multi_set_var(device_id2, BRIDGE_VARIABLES)
-        self.con.bgapi(BRIDGE, device_id1 + SPACE + device_id2)
+        self.bgapi(BRIDGE, arg=device_id1 + SPACE + device_id2, desc="bridge_call")
 
     def transfer_call(self, _from, _to):
         """转接"""
@@ -324,7 +324,7 @@ class InboundClient:
             val
         ]
         command = ' '.join(builder)
-        self.con.bgapi(command, EMPTY)
+        self.bgapi(command, desc ="set_var")
 
     def multi_set_var(self, uuid, params):
         builder = [
@@ -335,7 +335,7 @@ class InboundClient:
             builder1.append(k + "="+v)
         builder.append(';'.join(builder1))
         command = ''.join(builder)
-        self.con.bgapi(command, EMPTY)
+        self.bgapi(command, desc="multi_set_var")
 
     def record(self, uuid, action, path, limit):
         builder = [
@@ -375,19 +375,8 @@ class InboundClient:
             device_id,
             f"  -both 'set:hangup_after_bridge=false,set:park_after_bridge=true,set:{SIP_HEADER}{sipHeaderHoldMusic}={call_id},park:' inline "
         ]
-        _con = None
-        try:
-            arg = ''.join(builder)
-            _con = ESL.ESLconnection(self.host, self.port, self.password)
-            if _con.connected():
-                print('debugger::bridge_break, arg=%s'%arg, flush=True)
-                e = _con.api(TRANSFER, arg)
-                print('debugger::bridge_break success, arg=%s, event=%s' % (arg, e.serialize('json')), flush=True)
-        except:
-            traceback.print_exc()
-        finally:
-            if _con:
-                _con.disconnect()
+        arg = ''.join(builder)
+        self.api(TRANSFER, arg, "bridge_break")
 
     def play_file(self, call_id, device_id, file, sync):
         """放音"""
@@ -419,15 +408,30 @@ class InboundClient:
             " ",
             SMF_ALEG
         ]
+        arg = ''.join(builder)
+        self.api(UUID_BROADCAST, arg, "hold_play")
+
+    def api(self, command, arg=EMPTY, desc=""):
+        _con = None
+        try:
+            _con = ESL.ESLconnection(self.host, self.port, self.password)
+            if _con.connected():
+                e = _con.api(command, arg)
+                print('debugger::%s success, arg=%s, event=%s' % (desc, command + ' ' + arg, e.serialize('json')),
+                      flush=True)
+        except:
+            traceback.print_exc()
+        finally:
+            if _con:
+                _con.disconnect()
+
+    def bgapi(self, command, arg=EMPTY, desc=""):
         _con = None
         try:
-            arg = ''.join(builder)
-            print('debugger::hold_play, device_id=%s, play=%s' % (device_id, play), flush=True)
             _con = ESL.ESLconnection(self.host, self.port, self.password)
             if _con.connected():
-                print('debugger::hold_play, arg=%s' % arg, flush=True)
-                e = _con.api(UUID_BROADCAST, arg)
-                print('debugger::hold_play success, arg=%s, event=%s' % (arg, e.serialize('json')), flush=True)
+                e = _con.bgapi(command, arg)
+                print('debugger::%s success, arg=%s, event=%s' % (desc, command + ' '+arg, e.serialize('json')), flush=True)
         except:
             traceback.print_exc()
         finally:

+ 2 - 2
src/core/callcenter/esl/handler/channel_park_handler.py

@@ -46,10 +46,10 @@ class ChannelParkHandler(EslEventHandler):
         device_info = call_info.device_info_map.get(device_id)
         hold = self.cache.get_need_play_hold_music(call_id)
         print('debugger, ChannelParkHandler, hold=%s, device_info=%s' % (hold, device_info), flush=True)
-        if hold and device_info.device_type == DeviceType.CUSTOMER.code:
+        if hold and "false" != hold and device_info.device_type == DeviceType.CUSTOMER.code:
             self.inbound_client.hold_play(device_id, HOLD_MUSIC_PATH)
             self.cache.del_need_play_hold_music(call_id)
-            self.inbound_client.set_var(device_id, SIP_HEADER + sipHeaderHoldMusic, "false")
+            # self.inbound_client.set_var(device_id, SIP_HEADER + sipHeaderHoldMusic, "false")
 
     def process_fxo_calling(self, event):
         kwargs = json.loads(event.serialize('json'))

+ 2 - 0
src/core/callcenter/esl/utils/esl_event_util.py

@@ -392,6 +392,8 @@ 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)
+    if not call_id:
+        call_id = e.getHeader(VARIABLE_SIP_H_P_LIBRA_NEED_HOLD_MUSIC)
     return call_id
 
 def getOriginationUuid(e):