Quellcode durchsuchen

新增ai白名单,fix

Davidliu vor 2 Monaten
Ursprung
Commit
c5629c55f2
1 geänderte Dateien mit 18 neuen und 21 gelöschten Zeilen
  1. 18 21
      src/core/callcenter/esl/client.py

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

@@ -532,36 +532,33 @@ class OutboundClient:
                     kwargs['variable_sip_h_P-LIBRA-CallId'] = call_id
                     kwargs['variable_sip_h_P-LIBRA-DeviceId'] = device_id
 
-                    _bucket_call_type = 2
+                    bucket_call_type = 2
                     destination = None
                     service_category = 0
                     bucket = self.server.get_bucket(call_id)
                     whitelist = self.server.get_whitelist()
-                    _in_whitelist = self.in_whitelist(caller_number, whitelist)
+                    in_whitelist_type = self.in_whitelist(caller_number, whitelist)
                     self.server.logger.info('call incoming call_id=%s, caller_number=%s, device_id=%s, new_device_id=%s, in_whitelist=%s, bucket=%s', call_id, caller_number, device_id, new_device_id, _in_whitelist, bucket.name)
-                    if _in_whitelist:
-                        # 检查白名单
-                        if WhiteTypeEnum.AI == _in_whitelist:
-                            # 转到ai机器人
-                            _bucket_call_type = 0
+                    # 检查白名单
+                    if in_whitelist_type:
+                        if WhiteTypeEnum.AI == in_whitelist_type:
+                            bucket_call_type = 0
                             service_category = 1
-                            destination = self.bridge_ai(con, _bucket_call_type, call_id, device_id, new_device_id, **kwargs)
+                            destination = self.bridge_ai(con, bucket_call_type, call_id, device_id, new_device_id, **kwargs)
                         else:
-                            _bucket_call_type = 0
-                            self.transfer_custom(con, _bucket_call_type, call_id, device_id, new_device_id, **kwargs)
+                            bucket_call_type = 0
+                            self.transfer_custom(con, bucket_call_type, call_id, device_id, new_device_id, **kwargs)
                     else:
                         # 自然分流
                         if bucket and bucket.name == 'AI':
-                            #转到ai机器人
-                            _bucket_call_type = 1
+                            bucket_call_type = 1
                             service_category = 1
-                            destination = self.bridge_ai(con, _bucket_call_type, call_id,  device_id, new_device_id, **kwargs)
+                            destination = self.bridge_ai(con, bucket_call_type, call_id,  device_id, new_device_id, **kwargs)
                         else:
-                            # 传统服务
-                            self.transfer_custom(con, _bucket_call_type, call_id, device_id, new_device_id, **kwargs)
+                            self.transfer_custom(con, bucket_call_type, call_id, device_id, new_device_id, **kwargs)
 
-                    registry.CALL_INCOMING_REQUESTS.labels(f"{_bucket_call_type}").inc()
-                    self.server.dataHandleServer.create_record(call_id, caller_number, _bucket_call_type, service_category=service_category, user_id=destination if _bucket_call_type == 1 else None , user_name=  f"机器人{destination}" if _bucket_call_type ==1 else None)
+                    registry.CALL_INCOMING_REQUESTS.labels(f"{bucket_call_type}").inc()
+                    self.server.dataHandleServer.create_record(call_id, caller_number, bucket_call_type, service_category=service_category, user_id=destination if bucket_call_type == 1 else None , user_name=  f"机器人{destination}" if bucket_call_type ==1 else None)
 
                     try:
                         con.disconnect()
@@ -580,15 +577,15 @@ class OutboundClient:
                     # Ignore the error if socket is already closed
                     pass
 
-        def transfer_custom(self, con, _bucket_call_type, call_id, device_id, new_device_id, kwargs):
+        def transfer_custom(self, con, bucket_call_type, call_id, device_id, new_device_id, kwargs):
             self.answer(con, call_id, device_id)
-            self.build_call_info(CallType.INCOMING_AGENT_CALL.code, call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type, **kwargs)
+            self.build_call_info(CallType.INCOMING_AGENT_CALL.code, call_id, device_id, new_device_id, destination=None, bucket_type=bucket_call_type, **kwargs)
             self.server.agent.acd_service.transfer_to_agent(call_id, device_id)
 
-        def bridge_ai(self, con, _bucket_call_type, call_id, device_id, new_device_id, kwargs):
+        def bridge_ai(self, con, bucket_call_type, call_id, device_id, new_device_id, kwargs):
             destination = self.server.agent.register(**kwargs)
             self.server.logger.info("call_id=%s, device_id=%s, destination=%s, new_device_id=%s" % (call_id, device_id, destination, new_device_id))
-            self.build_call_info(CallType.INCOMING_BOT_CALL.code, call_id, device_id, new_device_id, str(destination), bucket_type=_bucket_call_type, **kwargs)
+            self.build_call_info(CallType.INCOMING_BOT_CALL.code, call_id, device_id, new_device_id, str(destination), bucket_type=bucket_call_type, **kwargs)
             self.server.cache.add_device_user_part(device_id, destination)
             con.execute("bridge", "{sip_h_P-LIBRA-CallId=%s,sip_h_P-LIBRA-DeviceId=%s,origination_uuid=%s}user/%s" % (call_id, new_device_id, new_device_id, destination), device_id)
             return destination