編輯個人資料改地方、圖片自帶出處

This commit is contained in:
Sahik committed 2026-11-26 11:45:04 +08:00
1 parent e75f0c95e9
commit 61e8580c72
27 files changed
+906 -160

No files matched your search

+1 -12
View File
@@ -9,6 +9,7 @@ from fastapi import APIRouter, Depends
from pydantic import BaseModel
from . import clock, config, notices
from .memes import list_memes # noqa: F401 (其他模組和測試也從這裡拿)
from .db import get_db, transaction
from .deps import current_user, fail
from .i18n import t
@@ -16,18 +17,6 @@ from .titles import fmt_uid
router = APIRouter()
MEME_EXTS = {".jpg", ".jpeg", ".png", ".webp", ".gif"}
def list_memes() -> list[str]:
if not config.MEME_DIR.is_dir():
return []
return sorted(
p.name for p in config.MEME_DIR.iterdir()
if p.is_file() and p.suffix.lower() in MEME_EXTS and not p.name.startswith(".")
)
def pick_meme() -> str | None:
memes = list_memes()
return secrets.choice(memes) if memes else None