feat: geräte-tokens im konto, neuester clip für kurzbefehle

Token-Verwaltung unter "Konto" (einmalige Anzeige, letzte Nutzung,
Widerruf), GET /api/clips/latest für iPhone-Kurzbefehle und Skripte,
README mit Anleitung für die Kurzbefehle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dbildhauerandClaude Opus 5.5 committed 2026-10-25 14:56:12 +01:00
1 parent d8377c8a04
commit 223eb4eb45
10 files changed
+505 -1

No files matched your search

+10
View File
@@ -59,6 +59,16 @@ def create_clip(body: ClipCreate, user: ApiUser, db: DbSession, background: Back
return clip
# Before /{clip_id}, which would otherwise answer "latest" with 422
@router.get("/latest", response_model=ClipOut)
def latest_clip(user: ApiUser, db: DbSession):
"""For scripts such as the iPhone shortcut: newest text/code clip, pinned or not."""
clip = clip_service.latest_text_clip(db, user.id)
if clip is None:
raise HTTPException(status.HTTP_404_NOT_FOUND, "Noch keine Clips.")
return clip
@router.get("/{clip_id}", response_model=ClipOut)
def get_clip(clip_id: int, user: ApiUser, db: DbSession):
return _get_visible_clip(db, user, clip_id)
+10
View File
@@ -90,6 +90,16 @@ def list_clips(
return list(items), total or 0
def latest_text_clip(db: Session, user_id: int) -> Clip | None:
"""The most recently changed visible text or code clip, ignoring pinning."""
return db.scalar(
select(Clip)
.where(visible_clip(user_id), Clip.kind != ClipKind.FILE)
.order_by(Clip.updated_at.desc(), Clip.id.desc())
.limit(1)
)
def get_clip(db: Session, user_id: int, clip_id: int) -> Clip | None:
"""A clip the user may see (own or in a shared project), else None."""
return db.scalar(select(Clip).where(Clip.id == clip_id, visible_clip(user_id)))