update:限制管理员上传,最长天数配置
This commit is contained in:
@@ -121,16 +121,14 @@ async def index(code: str, ip: str = Depends(error_ip_limit), s: AsyncSession =
|
||||
}
|
||||
|
||||
|
||||
@app.post('/share')
|
||||
async def share(background_tasks: BackgroundTasks, pwd: str = Header(default=None), text: str = Form(default=None),
|
||||
@app.post('/share', dependencies=[Depends(admin_required)], description='分享文件')
|
||||
async def share(background_tasks: BackgroundTasks, text: str = Form(default=None),
|
||||
style: str = Form(default='2'), value: int = Form(default=1), file: UploadFile = File(default=None),
|
||||
ip: str = Depends(upload_ip_limit), s: AsyncSession = Depends(get_session)):
|
||||
if not settings.ENABLE_UPLOAD and pwd != settings.ADMIN_PASSWORD:
|
||||
raise HTTPException(status_code=403, detail="上传功能已关闭")
|
||||
code = await get_code(s)
|
||||
if style == '2':
|
||||
if value > 7:
|
||||
raise HTTPException(status_code=400, detail="最大有效天数为7天")
|
||||
if value > settings.MAX_DAYS:
|
||||
raise HTTPException(status_code=400, detail=f"最大有效天数为{settings.MAX_DAYS}天")
|
||||
exp_time = datetime.datetime.now() + datetime.timedelta(days=value)
|
||||
exp_count = -1
|
||||
elif style == '1':
|
||||
|
||||
Reference in New Issue
Block a user