fix: 500 bei Lage-Erstellung - Platzhalter-Mismatch nach telegram_categories-Entfernung behoben
Dieser Commit ist enthalten in:
@@ -20,7 +20,7 @@ router = APIRouter(prefix="/api/incidents", tags=["incidents"])
|
|||||||
|
|
||||||
INCIDENT_UPDATE_COLUMNS = {
|
INCIDENT_UPDATE_COLUMNS = {
|
||||||
"title", "description", "type", "status", "refresh_mode",
|
"title", "description", "type", "status", "refresh_mode",
|
||||||
"refresh_interval", "retention_days", "international_sources", "include_telegram", "telegram_categories", "visibility",
|
"refresh_interval", "retention_days", "international_sources", "include_telegram", "visibility",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,14 +64,7 @@ async def _enrich_incident(db: aiosqlite.Connection, row: aiosqlite.Row) -> dict
|
|||||||
incident["article_count"] = article_count
|
incident["article_count"] = article_count
|
||||||
incident["source_count"] = source_count
|
incident["source_count"] = source_count
|
||||||
incident["created_by_username"] = user_row["email"] if user_row else "Unbekannt"
|
incident["created_by_username"] = user_row["email"] if user_row else "Unbekannt"
|
||||||
# telegram_categories: JSON-String -> Liste
|
|
||||||
tc = incident.get("telegram_categories")
|
|
||||||
if tc and isinstance(tc, str):
|
|
||||||
import json
|
|
||||||
try:
|
|
||||||
incident["telegram_categories"] = json.loads(tc)
|
|
||||||
except (json.JSONDecodeError, TypeError):
|
|
||||||
incident["telegram_categories"] = None
|
|
||||||
return incident
|
return incident
|
||||||
|
|
||||||
|
|
||||||
@@ -113,9 +106,9 @@ async def create_incident(
|
|||||||
now = datetime.now(TIMEZONE).strftime('%Y-%m-%d %H:%M:%S')
|
now = datetime.now(TIMEZONE).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
cursor = await db.execute(
|
cursor = await db.execute(
|
||||||
"""INSERT INTO incidents (title, description, type, refresh_mode, refresh_interval,
|
"""INSERT INTO incidents (title, description, type, refresh_mode, refresh_interval,
|
||||||
retention_days, international_sources, include_telegram, telegram_categories, visibility,
|
retention_days, international_sources, include_telegram, visibility,
|
||||||
tenant_id, created_by, created_at, updated_at)
|
tenant_id, created_by, created_at, updated_at)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||||
(
|
(
|
||||||
data.title,
|
data.title,
|
||||||
data.description,
|
data.description,
|
||||||
@@ -125,7 +118,6 @@ async def create_incident(
|
|||||||
data.retention_days,
|
data.retention_days,
|
||||||
1 if data.international_sources else 0,
|
1 if data.international_sources else 0,
|
||||||
1 if data.include_telegram else 0,
|
1 if data.include_telegram else 0,
|
||||||
__import__('json').dumps(data.telegram_categories) if data.telegram_categories else None,
|
|
||||||
data.visibility,
|
data.visibility,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
current_user["id"],
|
current_user["id"],
|
||||||
@@ -189,10 +181,7 @@ async def update_incident(
|
|||||||
for field, value in data.model_dump(exclude_none=True).items():
|
for field, value in data.model_dump(exclude_none=True).items():
|
||||||
if field not in INCIDENT_UPDATE_COLUMNS:
|
if field not in INCIDENT_UPDATE_COLUMNS:
|
||||||
continue
|
continue
|
||||||
if field == "telegram_categories":
|
if field in ("international_sources", "include_telegram"):
|
||||||
import json
|
|
||||||
updates[field] = json.dumps(value) if value else None
|
|
||||||
elif field in ("international_sources", "include_telegram"):
|
|
||||||
updates[field] = 1 if value else 0
|
updates[field] = 1 if value else 0
|
||||||
else:
|
else:
|
||||||
updates[field] = value
|
updates[field] = value
|
||||||
@@ -738,7 +727,6 @@ def _build_json_export(
|
|||||||
"summary": incident.get("summary"),
|
"summary": incident.get("summary"),
|
||||||
"international_sources": bool(incident.get("international_sources")),
|
"international_sources": bool(incident.get("international_sources")),
|
||||||
"include_telegram": bool(incident.get("include_telegram")),
|
"include_telegram": bool(incident.get("include_telegram")),
|
||||||
"telegram_categories": incident.get("telegram_categories"),
|
|
||||||
},
|
},
|
||||||
"sources": sources,
|
"sources": sources,
|
||||||
"fact_checks": [
|
"fact_checks": [
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren