debug9
This commit is contained in:
@@ -13,7 +13,7 @@ AMI_CHANNEL_FILTER = os.environ.get("AMI_CHANNEL_FILTER").split(", ")
|
||||
RECORDS_SERVER = os.environ.get("RECORDS_SERVER")
|
||||
|
||||
MEDODS_SERVER = os.environ.get("MEDODS_SERVER")
|
||||
MEDODS_TOKEN = os.environ.get("MEDODS_V1_TOKEN")
|
||||
MEDODS_TOKEN = os.environ.get("MEDODS_TOKEN")
|
||||
|
||||
DEBUG = os.environ.get("DEBUG", "False").lower() == "true"
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user