添加推送等级
This commit is contained in:
@ -25,12 +25,16 @@ async def read_event():
|
||||
if "push_url" not in config:
|
||||
logging.error("请配置push_url")
|
||||
return
|
||||
if "event_level" not in config:
|
||||
logging.error("请配置event_level")
|
||||
return
|
||||
|
||||
logging.info(config)
|
||||
user_map = config['user_ids']
|
||||
device_map = config['devices']
|
||||
event_map = config['event_type']
|
||||
push_url = config['push_url']
|
||||
event_level = config['event_level']
|
||||
redis_client = await aioredis.Redis(host="127.0.0.1", port=7019, password="SMHdFrlK")
|
||||
while True:
|
||||
try:
|
||||
@ -49,6 +53,9 @@ async def read_event():
|
||||
src_index = event_detail["srcIndex"]
|
||||
device_name = device_map.get(src_index, "未知设备")
|
||||
event_detail['deviceName'] = device_name
|
||||
# 默认事件等级为2
|
||||
if "eventLvl" not in event_detail:
|
||||
event_detail['eventLvl'] = 2
|
||||
# 根据设备名称获取 user_ids
|
||||
user_all = user_map.get("all", []) # 接受全部通知的用户
|
||||
user_ids = user_map.get(device_name, [])
|
||||
@ -65,6 +72,10 @@ async def read_event():
|
||||
if detection_field_name in event_detail['data']:
|
||||
event_detail['data']["_detectionResult"] = event_detail['data'].pop(
|
||||
detection_field_name)
|
||||
if isinstance(event_detail['data']["_detectionResult"], list) and len(
|
||||
event_detail['data']["_detectionResult"]):
|
||||
event_detail['data']["_detectionResult"] = \
|
||||
event_detail['data']["_detectionResult"][0]
|
||||
replace_image_host(event_detail['data']["_detectionResult"])
|
||||
logging.info(event_detail)
|
||||
try:
|
||||
@ -81,6 +92,9 @@ async def read_event():
|
||||
# 添加设备名称
|
||||
src_index = event["srcIndex"]
|
||||
device_name = device_map.get(src_index, "未知设备")
|
||||
# 默认事件等级为2
|
||||
if "eventLvl" not in event:
|
||||
event['eventLvl'] = 2
|
||||
# 根据设备名称获取 user_ids
|
||||
user_all = user_map.get("all", []) # 接受全部通知的用户
|
||||
user_ids = user_map.get(device_name, [])
|
||||
@ -94,6 +108,9 @@ async def read_event():
|
||||
detection_field_name = event['data']['eventType']
|
||||
if detection_field_name in event['data']:
|
||||
event['data']["_detectionResult"] = event['data'].pop(detection_field_name)
|
||||
if isinstance(event['data']["_detectionResult"], list) and len(
|
||||
event['data']["_detectionResult"]):
|
||||
event['data']["_detectionResult"] = event['data']["_detectionResult"][0]
|
||||
replace_image_host(event['data']["_detectionResult"])
|
||||
# 请求推送 api
|
||||
logging.info(event)
|
||||
|
Reference in New Issue
Block a user