refactor: extract star/notification/badge helpers into database.py and add enrich_items content module

Introduce `update_target_stars`, `get_target_owner_uid`, and `VOTABLE_TARGETS`/`STAR_TARGETS` in database.py; replace inline badge insertion with `award_badge()` and inline notification creation with `create_notification()` across auth, comments, and follow routers; add `enrich_items()` in new content module to centralize post/gist list assembly and remove duplicated enrichment logic from feed and gists routers.
This commit is contained in:
2026-05-23 06:34:13 +00:00
parent ab1121a42a
commit d7d8314da0
34 changed files with 211 additions and 367 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ from pathlib import Path
from fastapi import APIRouter, Request
from fastapi.responses import JSONResponse
from devplacepy.database import get_table, get_setting, get_int_setting
from devplacepy.utils import require_user
from devplacepy.utils import require_user_api
from devplacepy.attachments import store_attachment, delete_attachment as _delete_attachment, ALLOWED_UPLOAD_TYPES
logger = logging.getLogger(__name__)
@@ -12,7 +12,7 @@ router = APIRouter()
@router.post("/upload")
async def upload_file(request: Request):
user = require_user(request)
user = require_user_api(request)
form = await request.form()
file = form.get("file")
@@ -49,7 +49,7 @@ async def upload_file(request: Request):
@router.delete("/delete/{attachment_uid}")
async def delete_attachment_route(request: Request, attachment_uid: str):
user = require_user(request)
user = require_user_api(request)
att = get_table("attachments").find_one(uid=attachment_uid)
if not att:
return JSONResponse({"error": "Attachment not found"}, status_code=404)