fix: Audio-Dateien nie auf Frontpage + Sprach-Regeln im Triage-Prompt
- media_publish_flags: .ogg/.mp3/.wav auf '0' (nicht veröffentlichen) - TRIAGE_PROMPT: Sprachnachrichten-Regeln (dünn=Zusammenfassung, reichhaltig=1:1) - threading-Import-Fix in WhatsApp/Telegram-Webhooks
This commit is contained in:
@@ -242,6 +242,15 @@ WICHTIG zu display_text:
|
|||||||
kopiere ihn 1:1 als display_text.
|
kopiere ihn 1:1 als display_text.
|
||||||
- Wenn der Text kurz, unstrukturiert oder noisy ist:
|
- Wenn der Text kurz, unstrukturiert oder noisy ist:
|
||||||
formuliere einen sauberen, lesbaren Display-Text (2-4 Sätze), der die Kernaussage wiedergibt.
|
formuliere einen sauberen, lesbaren Display-Text (2-4 Sätze), der die Kernaussage wiedergibt.
|
||||||
|
- 🎤 SPRACHNACHRICHTEN (erkennbar an \"🎤\" am Anfang):
|
||||||
|
- Wenn der Inhalt REICHHALTIG ist (≥200 Zeichen, mehrere Fakten, klare News):
|
||||||
|
Transkription 1:1 als display_text übernehmen.
|
||||||
|
- Wenn der Inhalt DÜNN ist (nur \"Spiel X gibt's an Stand Y für €Z\"):
|
||||||
|
Kurze LLM-Zusammenfassung (1 Satz), nicht die ganze Transkription.
|
||||||
|
Grund: Die Sprachnachricht selbst wird NICHT veröffentlicht (nur der Text).
|
||||||
|
- 🖼️ FOTO + 🎤 SPRACHNACHRICHT kombiniert (erkennbar an \"[Bild ohne Text]\" + \"🎤\"):
|
||||||
|
display_text = Transkription der Sprachnachricht (mit Foto-Regeln wie oben).
|
||||||
|
Das Foto wird automatisch mitveröffentlicht, die Audio-Datei NICHT.
|
||||||
- Entferne dabei: Füllwörter, Emoji-Overload, unhöfliche Formulierungen, irrelevante Anhängsel.
|
- Entferne dabei: Füllwörter, Emoji-Overload, unhöfliche Formulierungen, irrelevante Anhängsel.
|
||||||
- Der display_text MUSS auf Deutsch sein (englische Eigennamen/Fachbegriffe sind OK).
|
- Der display_text MUSS auf Deutsch sein (englische Eigennamen/Fachbegriffe sind OK).
|
||||||
- Maximal 500 Zeichen.
|
- Maximal 500 Zeichen.
|
||||||
@@ -436,11 +445,27 @@ def triage_submission(db, submission_id: int) -> dict:
|
|||||||
if len(display_text) > 1000:
|
if len(display_text) > 1000:
|
||||||
display_text = display_text[:997] + "..."
|
display_text = display_text[:997] + "..."
|
||||||
|
|
||||||
|
# ── Media-Publish-Flags: Audio nicht veröffentlichen ────────────
|
||||||
|
# Regel: Sprachnachrichten (.ogg/.mp3/.wav) sollen NIE auf der
|
||||||
|
# Frontpage als Audio-Player erscheinen. Nur die Transkription
|
||||||
|
# (display_text) wird gezeigt. Bilder/Videos bleiben sichtbar.
|
||||||
|
media_flags = None
|
||||||
|
if row["media_path"]:
|
||||||
|
paths = row["media_path"].split("||")
|
||||||
|
flags = []
|
||||||
|
for p in paths:
|
||||||
|
ext = os.path.splitext(p)[1].lower()
|
||||||
|
if ext in (".ogg", ".mp3", ".wav"):
|
||||||
|
flags.append("0") # Audio: nicht veröffentlichen
|
||||||
|
else:
|
||||||
|
flags.append("1") # Bild/Video: veröffentlichen
|
||||||
|
media_flags = ",".join(flags)
|
||||||
|
|
||||||
# ── DB-Update ───────────────────────────────────────────────────
|
# ── DB-Update ───────────────────────────────────────────────────
|
||||||
db.execute(
|
db.execute(
|
||||||
"""UPDATE submissions
|
"""UPDATE submissions
|
||||||
SET triage_tier=?, triage_reasons=?, triage_at=CURRENT_TIMESTAMP,
|
SET triage_tier=?, triage_reasons=?, triage_at=CURRENT_TIMESTAMP,
|
||||||
public=?, status=?, display_text=?,
|
public=?, status=?, display_text=?, media_publish_flags=?,
|
||||||
published_at=CASE WHEN ? = 1 THEN COALESCE(published_at, CURRENT_TIMESTAMP) ELSE published_at END
|
published_at=CASE WHEN ? = 1 THEN COALESCE(published_at, CURRENT_TIMESTAMP) ELSE published_at END
|
||||||
WHERE id=?""",
|
WHERE id=?""",
|
||||||
(
|
(
|
||||||
@@ -449,6 +474,7 @@ def triage_submission(db, submission_id: int) -> dict:
|
|||||||
1 if tier == 1 else 0,
|
1 if tier == 1 else 0,
|
||||||
"published" if tier == 1 else ("blocked" if tier == 3 else "pending"),
|
"published" if tier == 1 else ("blocked" if tier == 3 else "pending"),
|
||||||
display_text,
|
display_text,
|
||||||
|
media_flags,
|
||||||
tier,
|
tier,
|
||||||
submission_id,
|
submission_id,
|
||||||
),
|
),
|
||||||
@@ -979,6 +1005,7 @@ def whatsapp_webhook():
|
|||||||
return "OK", 200
|
return "OK", 200
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
import threading
|
||||||
entries = body.get("entry", [])
|
entries = body.get("entry", [])
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
|
||||||
@@ -1159,7 +1186,6 @@ def whatsapp_webhook():
|
|||||||
|
|
||||||
# Transcribe audio in background (non-blocking)
|
# Transcribe audio in background (non-blocking)
|
||||||
if msg_type == "audio" and media_path:
|
if msg_type == "audio" and media_path:
|
||||||
import threading
|
|
||||||
sub_id = recent["id"] if thread_found else db.execute(
|
sub_id = recent["id"] if thread_found else db.execute(
|
||||||
"SELECT last_insert_rowid()"
|
"SELECT last_insert_rowid()"
|
||||||
).fetchone()[0]
|
).fetchone()[0]
|
||||||
@@ -1171,7 +1197,6 @@ def whatsapp_webhook():
|
|||||||
|
|
||||||
# Transcribe video in background
|
# Transcribe video in background
|
||||||
if msg_type == "video" and media_path:
|
if msg_type == "video" and media_path:
|
||||||
import threading
|
|
||||||
sub_id = recent["id"] if thread_found else db.execute(
|
sub_id = recent["id"] if thread_found else db.execute(
|
||||||
"SELECT last_insert_rowid()"
|
"SELECT last_insert_rowid()"
|
||||||
).fetchone()[0]
|
).fetchone()[0]
|
||||||
@@ -1183,7 +1208,6 @@ def whatsapp_webhook():
|
|||||||
|
|
||||||
# Auto-summarize text/image submissions (LLM hall + summary)
|
# Auto-summarize text/image submissions (LLM hall + summary)
|
||||||
if msg_type in ("text", "image") and not thread_found and content and len(content.strip()) > 20:
|
if msg_type in ("text", "image") and not thread_found and content and len(content.strip()) > 20:
|
||||||
import threading
|
|
||||||
sub_id = db.execute("SELECT last_insert_rowid()").fetchone()[0]
|
sub_id = db.execute("SELECT last_insert_rowid()").fetchone()[0]
|
||||||
# Only if regex didn't already find a halle
|
# Only if regex didn't already find a halle
|
||||||
if not halle:
|
if not halle:
|
||||||
@@ -4600,6 +4624,7 @@ def telegram_webhook():
|
|||||||
return "OK", 200
|
return "OK", 200
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
import threading
|
||||||
msg = body.get("message", {})
|
msg = body.get("message", {})
|
||||||
if not msg:
|
if not msg:
|
||||||
return "OK", 200
|
return "OK", 200
|
||||||
|
|||||||
Reference in New Issue
Block a user