投稿に制限を設ける

This commit is contained in:
yuuki 2025-03-04 00:50:33 +00:00
parent 0fb53bfd4d
commit 4624f2db92

4
app.py
View file

@ -170,7 +170,7 @@ async def api_get(id: str = None):
res.headers["CDN-Cache-Control"] = f"max-age=60" res.headers["CDN-Cache-Control"] = f"max-age=60"
return res return res
@app.post("/api/litey/post") @app.post("/api/litey/post", dependencies=[Depends(RateLimiter(times=4, seconds=3600))])
async def api_post(item: LiteYItem, req: Request): async def api_post(item: LiteYItem, req: Request):
ctx["mongo_client"].litey.notes.insert_one({ ctx["mongo_client"].litey.notes.insert_one({
"id": str(uuid4()), "id": str(uuid4()),
@ -210,7 +210,7 @@ async def api_ng_get():
res.headers["CDN-Cache-Control"] = f"max-age=60" res.headers["CDN-Cache-Control"] = f"max-age=60"
return res return res
@app.post("/api/ng/post") @app.post("/api/ng/post", dependencies=[Depends(RateLimiter(times=1, seconds=86400))])
async def api_ng_post(item: NGItem): async def api_ng_post(item: NGItem):
ctx["mongo_client"].litey.ngs.insert_one({ ctx["mongo_client"].litey.ngs.insert_one({
"word": item.word "word": item.word