habulaj commited on
Commit
f767469
·
verified ·
1 Parent(s): 9a3420f

Update routes/support.py

Browse files
Files changed (1) hide show
  1. routes/support.py +11 -0
routes/support.py CHANGED
@@ -317,6 +317,17 @@ async def respond_ticket(
317
 
318
  # 3. Espera 1 segundo antes de enviar a mensagem
319
  await asyncio.sleep(1)
 
 
 
 
 
 
 
 
 
 
 
320
 
321
  # 4. Criar mensagem
322
  message_payload = {
 
317
 
318
  # 3. Espera 1 segundo antes de enviar a mensagem
319
  await asyncio.sleep(1)
320
+
321
+ # 3.1. Reabrir ticket se estiver fechado
322
+ if ticket.get("finished", False) is True:
323
+ async with aiohttp.ClientSession() as session:
324
+ async with session.patch(
325
+ f"{SUPABASE_URL}/rest/v1/Tickets?id=eq.{body.ticket_id}",
326
+ headers={**SUPABASE_ROLE_HEADERS, "Prefer": "return=representation"},
327
+ json={"finished": False, "finished_date": None}
328
+ ) as reopen_resp:
329
+ if reopen_resp.status != 200:
330
+ raise HTTPException(status_code=500, detail="Erro ao reabrir o ticket")
331
 
332
  # 4. Criar mensagem
333
  message_payload = {