"""Trash REST API — list / restore / purge soft-deleted content by batch.""" from __future__ import annotations from quart import Blueprint, g, jsonify from scribe.auth import login_required import scribe.services.trash as trash_svc trash_bp = Blueprint("trash", __name__, url_prefix="/api/trash") def _uid() -> int: return g.user.id @trash_bp.get("") @login_required async def list_trash(): return jsonify({"batches": await trash_svc.list_trash(_uid())}) @trash_bp.post("//restore") @login_required async def restore_batch(batch_id: str): n = await trash_svc.restore(_uid(), batch_id) return jsonify({"restored": n}) @trash_bp.delete("/") @login_required async def purge_batch(batch_id: str): n = await trash_svc.purge(_uid(), batch_id) return jsonify({"purged": n})