This commit is contained in:
quantulr
2024-02-23 10:11:42 +08:00
parent 630ad7ac9b
commit 31b4ef217b
6 changed files with 309 additions and 94 deletions

View File

@ -50,7 +50,9 @@ async def read_event():
device_name = device_map.get(src_index, "未知设备")
event_detail['deviceName'] = device_name
# 根据设备名称获取 user_ids
user_all = user_map.get("all", []) # 接受全部通知的用户
user_ids = user_map.get(device_name, [])
user_ids = user_ids + user_all
event_detail['userIds'] = user_ids
# 添加其他字段
event_detail["eventLvl"] = event['eventLvl']
@ -61,7 +63,8 @@ async def read_event():
if "eventType" in event_detail['data']:
detection_field_name = event_detail['data']['eventType']
if detection_field_name in event_detail['data']:
event_detail['data']["_detectionResult"] = event_detail['data'].pop(detection_field_name)
event_detail['data']["_detectionResult"] = event_detail['data'].pop(
detection_field_name)
logging.info(event_detail)
try:
push_resp = requests.post(push_url, json=event_detail).content.decode('utf-8')
@ -78,7 +81,9 @@ async def read_event():
src_index = event["srcIndex"]
device_name = device_map.get(src_index, "未知设备")
# 根据设备名称获取 user_ids
user_all = user_map.get("all", []) # 接受全部通知的用户
user_ids = user_map.get(device_name, [])
user_ids = user_ids + user_all
event['deviceName'] = device_name
event['userIds'] = user_ids
if "data" in event:

View File

@ -1,14 +0,0 @@
import io
import json
import requests
if __name__ == '__main__':
image_content = requests.get(
"http://47.102.206.10:8086/api/uploads/image/20231101/5bedf085-841a-48cc-bca2-9c9b2c751b48.jpeg").content
image_bytes = io.BytesIO(image_content)
# files = {"file": image_bytes}
data = {"file": "67tgby6y67tg", "file_bytes": "fsfadfsdffadf"}
resp = requests.post("http://localhost:8000/upload",
files={"file": image_bytes}).content.decode('utf-8')
print(resp)