ProdLaunch

This commit is contained in:
2026-06-18 15:14:10 +02:00
parent d8f58640e5
commit 4c90a7c1a3
12 changed files with 1412 additions and 5 deletions
+6 -2
View File
@@ -923,9 +923,13 @@ async def get_thread(
# Carica ricorsivamente tutti i messaggi del thread dalla radice
# Limita a posta_certificata (esclude accettazioni, consegne, ecc.)
# Depth limit per evitare stack overflow su thread eccezionalmente profondi
_THREAD_MAX_DEPTH = 100
thread_messages: list[Message] = []
async def _collect(msg_id: uuid.UUID) -> None:
async def _collect(msg_id: uuid.UUID, depth: int = 0) -> None:
if depth >= _THREAD_MAX_DEPTH:
return
result = await db.execute(
select(Message)
.where(
@@ -951,7 +955,7 @@ async def get_thread(
)
children = list(children_result.scalars().all())
for child in children:
await _collect(child.id)
await _collect(child.id, depth + 1)
await _collect(root_id)