Update routes/support.py
Browse files- routes/support.py +7 -5
routes/support.py
CHANGED
@@ -372,7 +372,7 @@ async def close_ticket(
|
|
372 |
body: CloseTicketRequest,
|
373 |
user_token: str = Header(None, alias="User-key")
|
374 |
):
|
375 |
-
user_id = await verify_user_token(user_token)
|
376 |
logger.info(f"User ID verified: {user_id}")
|
377 |
|
378 |
finished_date = datetime.utcnow().isoformat()
|
@@ -399,7 +399,8 @@ async def close_ticket(
|
|
399 |
|
400 |
# Atualizar o finished_date sem modificar o status finished, se já estiver fechado
|
401 |
update_payload = {"finished_date": finished_date}
|
402 |
-
|
|
|
403 |
try:
|
404 |
async with aiohttp.ClientSession() as session:
|
405 |
async with session.patch(
|
@@ -411,14 +412,15 @@ async def close_ticket(
|
|
411 |
json=update_payload
|
412 |
) as update_resp:
|
413 |
logger.info(f"Response status: {update_resp.status}")
|
|
|
|
|
414 |
|
415 |
if update_resp.status == 204:
|
416 |
logger.info(f"Ticket {body.ticket_id} updated successfully.")
|
417 |
return {"message": "Ticket closed successfully", "ticket_id": body.ticket_id}
|
418 |
else:
|
419 |
-
|
420 |
-
|
421 |
-
raise HTTPException(status_code=500, detail=f"Error updating ticket: {error_detail}")
|
422 |
except aiohttp.ClientError as e:
|
423 |
logger.error(f"AIOHTTP client error: {str(e)}")
|
424 |
raise HTTPException(status_code=500, detail=f"Client error: {str(e)}")
|
|
|
372 |
body: CloseTicketRequest,
|
373 |
user_token: str = Header(None, alias="User-key")
|
374 |
):
|
375 |
+
user_id = await verify_user_token(user_token)
|
376 |
logger.info(f"User ID verified: {user_id}")
|
377 |
|
378 |
finished_date = datetime.utcnow().isoformat()
|
|
|
399 |
|
400 |
# Atualizar o finished_date sem modificar o status finished, se já estiver fechado
|
401 |
update_payload = {"finished_date": finished_date}
|
402 |
+
logger.info(f"Updating ticket with payload: {update_payload}")
|
403 |
+
|
404 |
try:
|
405 |
async with aiohttp.ClientSession() as session:
|
406 |
async with session.patch(
|
|
|
412 |
json=update_payload
|
413 |
) as update_resp:
|
414 |
logger.info(f"Response status: {update_resp.status}")
|
415 |
+
response_data = await update_resp.text()
|
416 |
+
logger.info(f"Response data: {response_data}")
|
417 |
|
418 |
if update_resp.status == 204:
|
419 |
logger.info(f"Ticket {body.ticket_id} updated successfully.")
|
420 |
return {"message": "Ticket closed successfully", "ticket_id": body.ticket_id}
|
421 |
else:
|
422 |
+
logger.error(f"Error updating ticket: {response_data}")
|
423 |
+
raise HTTPException(status_code=500, detail=f"Error updating ticket: {response_data}")
|
|
|
424 |
except aiohttp.ClientError as e:
|
425 |
logger.error(f"AIOHTTP client error: {str(e)}")
|
426 |
raise HTTPException(status_code=500, detail=f"Client error: {str(e)}")
|