diff --git a/src/fabledassistant/routes/notes.py b/src/fabledassistant/routes/notes.py index a515969..d59e218 100644 --- a/src/fabledassistant/routes/notes.py +++ b/src/fabledassistant/routes/notes.py @@ -553,6 +553,39 @@ async def get_version_route(note_id: int, version_id: int): return jsonify(version.to_dict(include_body=True)) +@notes_bp.route("//versions//pin", methods=["POST"]) +@login_required +async def pin_version_route(note_id: int, version_id: int): + """Mark a version as manually pinned. Body: {"label": str | null}.""" + uid = get_current_user_id() + data = await request.get_json() or {} + label = data.get("label") + if label is not None and not isinstance(label, str): + return jsonify({"error": "label must be a string or null"}), 400 + from fabledassistant.services.version_pinning import pin_version + try: + version = await pin_version(uid, note_id, version_id, label=label) + except ValueError as e: + return jsonify({"error": str(e)}), 400 + if version is None: + return not_found("Version") + return jsonify(version.to_dict(include_body=False)) + + +@notes_bp.route( + "//versions//pin", methods=["DELETE"], +) +@login_required +async def unpin_version_route(note_id: int, version_id: int): + """Downgrade a manually-pinned version back to rolling.""" + uid = get_current_user_id() + from fabledassistant.services.version_pinning import unpin_version + version = await unpin_version(uid, note_id, version_id) + if version is None: + return not_found("Version") + return jsonify(version.to_dict(include_body=False)) + + # ── Graph route ──────────────────────────────────────────────────────────────── @notes_bp.route("/graph", methods=["GET"])