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")
|
RECORDS_SERVER = os.environ.get("RECORDS_SERVER")
|
||||||
|
|
||||||
MEDODS_SERVER = os.environ.get("MEDODS_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"
|
DEBUG = os.environ.get("DEBUG", "False").lower() == "true"
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ from aiohttp import ClientSession
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
|
|
||||||
def loggingDict(title: str, data: dict) -> None:
|
def loggingDict(title: str, data: dict, call_id: str) -> None:
|
||||||
call_id = data.get("call_session_id", "None")
|
|
||||||
today = datetime.now().strftime("%Y-%m-%d")
|
today = datetime.now().strftime("%Y-%m-%d")
|
||||||
file_name = f"log/{today}/{call_id}.log"
|
file_name = f"log/{today}/{call_id}.log"
|
||||||
if not os.path.exists(f"log/{today}"):
|
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)}")
|
logging.error(f"Request failed: {str(e)}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
call_id = body["call_session_id"]
|
||||||
data = {"call": body}
|
data = {"call": body}
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": f"Bearer {config.MEDODS_TOKEN}",
|
"Authorization": f"Bearer {config.MEDODS_TOKEN}",
|
||||||
}
|
}
|
||||||
if config.DEBUG:
|
if config.DEBUG:
|
||||||
loggingDict("Sending data to Medods", data)
|
loggingDict("Sending data to Medods", data, call_id)
|
||||||
loggingDict("Headers", headers)
|
loggingDict("Headers", headers, call_id)
|
||||||
r = await post_request(url=config.MEDODS_SERVER, headers=headers, json=data)
|
r = await post_request(url=config.MEDODS_SERVER, headers=headers, json=data)
|
||||||
try:
|
try:
|
||||||
res = {
|
res = {
|
||||||
@@ -55,7 +55,7 @@ async def send_post_request(body: dict):
|
|||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
res = {}
|
res = {}
|
||||||
loggingDict("Recieved data from Medods:", res)
|
loggingDict("Recieved data from Medods:", res, call_id)
|
||||||
else:
|
else:
|
||||||
await post_request(url=config.MEDODS_SERVER, headers=headers, json=data)
|
await post_request(url=config.MEDODS_SERVER, headers=headers, json=data)
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ async def call_lost(call_session_id):
|
|||||||
body = {
|
body = {
|
||||||
"status": "call_lost",
|
"status": "call_lost",
|
||||||
"call_session_id": call_session_id,
|
"call_session_id": call_session_id,
|
||||||
"responsibles": config.OPERATORS,
|
"responsibles": [{"id": 777}],
|
||||||
}
|
}
|
||||||
await send_post_request(body)
|
await send_post_request(body)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user