Feature/Fix: Routen-Navi, Badge-Klick-Fix, Forum-Edit, Chat-Unread-Refresh
- Routen: Navi-Button öffnet Apple Maps/Google Maps mit Start/Ziel-GPS - Routen: Teilen-Button nutzt navigator.share() mit Fallback auf Clipboard - Routen: Icon 'share' → 'arrow-square-out' (war nicht im Sprite) - Nav-Badge: pointer-events:none → Badge blockiert keine Klicks mehr - visibilitychange: Badges + Chat-Liste sofort refresh bei App-Rückkehr - Forum: eigene Threads und Antworten bearbeiten (PATCH /threads/content, PATCH /posts) - SW by-v238, APP_VER 215
This commit is contained in:
parent
289158b2cd
commit
7a25ccae90
8 changed files with 169 additions and 11 deletions
|
|
@ -37,6 +37,13 @@ class ThreadPatch(BaseModel):
|
|||
is_pinned: Optional[int] = None
|
||||
is_locked: Optional[int] = None
|
||||
|
||||
class ThreadUpdate(BaseModel):
|
||||
titel: Optional[str] = None
|
||||
text: Optional[str] = None
|
||||
|
||||
class PostUpdate(BaseModel):
|
||||
text: str
|
||||
|
||||
class LikeBody(BaseModel):
|
||||
target_type: str # 'thread' | 'post'
|
||||
target_id: int
|
||||
|
|
@ -330,6 +337,38 @@ async def create_post(thread_id: int, data: PostCreate, user=Depends(get_current
|
|||
return pd
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# PATCH /api/forum/threads/{id}/content — Besitzer: titel/text
|
||||
# ------------------------------------------------------------------
|
||||
@router.patch("/threads/{thread_id}/content")
|
||||
async def update_thread_content(thread_id: int, data: ThreadUpdate, user=Depends(get_current_user)):
|
||||
with db() as conn:
|
||||
t = conn.execute("SELECT user_id FROM forum_threads WHERE id=?", (thread_id,)).fetchone()
|
||||
if not t: raise HTTPException(404, "Thread nicht gefunden.")
|
||||
if t["user_id"] != user["id"]: raise HTTPException(403, "Nicht dein Beitrag.")
|
||||
updates, vals = [], []
|
||||
if data.titel is not None and data.titel.strip():
|
||||
updates.append("titel=?"); vals.append(data.titel.strip())
|
||||
if data.text is not None:
|
||||
updates.append("text=?"); vals.append(data.text.strip())
|
||||
if not updates: return {"ok": True}
|
||||
conn.execute(f"UPDATE forum_threads SET {','.join(updates)} WHERE id=?", (*vals, thread_id))
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# PATCH /api/forum/posts/{id} — Besitzer: text
|
||||
# ------------------------------------------------------------------
|
||||
@router.patch("/posts/{post_id}")
|
||||
async def update_post(post_id: int, data: PostUpdate, user=Depends(get_current_user)):
|
||||
with db() as conn:
|
||||
p = conn.execute("SELECT user_id FROM forum_posts WHERE id=?", (post_id,)).fetchone()
|
||||
if not p: raise HTTPException(404, "Beitrag nicht gefunden.")
|
||||
if p["user_id"] != user["id"]: raise HTTPException(403, "Nicht dein Beitrag.")
|
||||
conn.execute("UPDATE forum_posts SET text=? WHERE id=?", (data.text.strip(), post_id))
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# DELETE /api/forum/posts/{id}
|
||||
# ------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue