From 413442ba5d5734df84a943a901013ea51e6ee3ed Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Tue, 28 Oct 2025 16:36:11 +0000 Subject: [PATCH] feat(api): integrate user note field into api endpoints --- core/scripts/webpanel/routers/api/v1/schema/user.py | 3 +++ core/scripts/webpanel/routers/api/v1/user.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/scripts/webpanel/routers/api/v1/schema/user.py b/core/scripts/webpanel/routers/api/v1/schema/user.py index 4a2ddca..311033c 100644 --- a/core/scripts/webpanel/routers/api/v1/schema/user.py +++ b/core/scripts/webpanel/routers/api/v1/schema/user.py @@ -11,6 +11,7 @@ class UserInfoResponse(BaseModel): account_creation_date: Optional[str] = None blocked: bool unlimited_ip: bool = Field(False, alias='unlimited_user') + note: Optional[str] = None status: Optional[str] = None upload_bytes: Optional[int] = None download_bytes: Optional[int] = None @@ -30,6 +31,7 @@ class AddUserInputBody(BaseModel): password: Optional[str] = None creation_date: Optional[str] = None unlimited: bool = False + note: Optional[str] = None @field_validator('username') def validate_username(cls, v): @@ -61,6 +63,7 @@ class EditUserInputBody(BaseModel): renew_creation_date: bool = False blocked: Optional[bool] = None unlimited_ip: Optional[bool] = None + note: Optional[str] = None @field_validator('new_username') def validate_new_username(cls, v): diff --git a/core/scripts/webpanel/routers/api/v1/user.py b/core/scripts/webpanel/routers/api/v1/user.py index 3136814..79b8894 100644 --- a/core/scripts/webpanel/routers/api/v1/user.py +++ b/core/scripts/webpanel/routers/api/v1/user.py @@ -47,7 +47,7 @@ async def add_user_api(body: AddUserInputBody): detail=f"{str(e)}") try: - cli_api.add_user(body.username, body.traffic_limit, body.expiration_days, body.password, body.creation_date, body.unlimited) + cli_api.add_user(body.username, body.traffic_limit, body.expiration_days, body.password, body.creation_date, body.unlimited, body.note) return DetailResponse(detail=f'User {body.username} has been added.') except cli_api.CommandExecutionError as e: if "User already exists" in str(e): @@ -172,7 +172,7 @@ async def edit_user_api(username: str, body: EditUserInputBody): cli_api.kick_users_by_name([username]) cli_api.traffic_status(display_output=False) cli_api.edit_user(username, body.new_username, body.new_traffic_limit, body.new_expiration_days, - body.renew_password, body.renew_creation_date, body.blocked, body.unlimited_ip) + body.renew_password, body.renew_creation_date, body.blocked, body.unlimited_ip, body.note) return DetailResponse(detail=f'User {username} has been edited.') except Exception as e: raise HTTPException(status_code=400, detail=f'Error: {str(e)}')