This commit is contained in:
Dev PC
2025-08-05 12:22:06 +03:00
parent eff17e9b91
commit fe140474d9
2 changed files with 7 additions and 7 deletions
+6 -6
View File
@@ -7,8 +7,7 @@ from aiohttp import ClientSession
import aiohttp
def loggingDict(title: str, data: dict) -> None:
call_id = data.get("call_session_id", "None")
def loggingDict(title: str, data: dict, call_id: str) -> None:
today = datetime.now().strftime("%Y-%m-%d")
file_name = f"log/{today}/{call_id}.log"
if not os.path.exists(f"log/{today}"):
@@ -38,14 +37,15 @@ async def send_post_request(body: dict):
logging.error(f"Request failed: {str(e)}")
return None
call_id = body["call_session_id"]
data = {"call": body}
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {config.MEDODS_TOKEN}",
}
if config.DEBUG:
loggingDict("Sending data to Medods", data)
loggingDict("Headers", headers)
loggingDict("Sending data to Medods", data, call_id)
loggingDict("Headers", headers, call_id)
r = await post_request(url=config.MEDODS_SERVER, headers=headers, json=data)
try:
res = {
@@ -55,7 +55,7 @@ async def send_post_request(body: dict):
}
except:
res = {}
loggingDict("Recieved data from Medods:", res)
loggingDict("Recieved data from Medods:", res, call_id)
else:
await post_request(url=config.MEDODS_SERVER, headers=headers, json=data)
@@ -92,7 +92,7 @@ async def call_lost(call_session_id):
body = {
"status": "call_lost",
"call_session_id": call_session_id,
"responsibles": config.OPERATORS,
"responsibles": [{"id": 777}],
}
await send_post_request(body)