This commit is contained in:
quantulr
2024-01-30 13:06:27 +08:00
parent 8128bfb5f9
commit 4e62811f16
3 changed files with 18 additions and 10 deletions

Binary file not shown.

View File

@ -88,18 +88,26 @@ async def read_event():
event_type = event['eventType']
event_type_str = mapping.get(event_type, "未知事件类型")
event['eventType'] = event_type_str
# ip address
if "data" in event:
# 如果存在 data 属性
# ip_address
ip_address = event["data"]["ipAddress"]
# 根据 ip_address 获取对应设备名称
device_name = device_map.get(ip_address, "未知设备")
event['deviceName'] = device_name
# print(event['data'][event['data']['eventType']])
# TODO: 根据 ip_address 获取对应 userid
event['data']['deviceName'] = device_name
# 根据 ip_address 获取对应 userid 数组
user_ids = user_map.get(ip_address, [])
event['userIds'] = user_ids
event['data']['userIds'] = user_ids
# 替换分析结果字段
if "eventType" in event['data']:
detection_field_name = event['data']['eventType']
if detection_field_name in event['data']:
event['data']["_detectionResult"] = event['data'].pop(detection_field_name)
# TODO: 请求推送 api
#
print(event, device_name)
print(event)
except Exception as e:
print("error: ", e)