mirror of
https://github.com/rommapp/romm.git
synced 2026-07-01 08:16:21 +00:00
- Fix broken path construction in FSSyncHandler: build_* methods now return relative paths; sync_watcher uses paths relative to sync base instead of CWD (was completely non-functional in production) - Fix SSH connection leak in push-pull task: conn.close() now in finally - Add log.warning for disabled SSH host key verification - Fix race condition in session operation counter: use atomic SQL increment instead of read-then-write - Extract _increment_session_counter helper, add exc_info to warnings - Replace legacy session.query() with select() in sync_sessions_handler - Fix orphaned session: trigger_push_pull now passes session_id to job - Fix wasteful SSH download when no matched_save exists - Fix BaseModel import collision in sync.py (pydantic -> project base) - Fix ORM mutation in UserSchema.from_orm_with_request: set field on schema instance instead of mutating live ORM object - Mask ssh_password and ssh_key_path in DeviceSchema API response - Fix migration PostgreSQL compatibility: condition ON UPDATE clause on MySQL, drop enum in downgrade - Rename copy-paste artifact rom_user_status_enum
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from typing import NotRequired, TypedDict, get_type_hints
|
|
|
|
from pydantic import ConfigDict
|
|
from starlette.requests import Request
|
|
|
|
from handler.metadata.ra_handler import RAUserProgression
|
|
from models.user import Role, User
|
|
|
|
from .base import BaseModel, UTCDatetime
|
|
|
|
RAProgression = TypedDict( # type: ignore[misc]
|
|
"RAProgression",
|
|
{k: NotRequired[v] for k, v in get_type_hints(RAUserProgression).items()}, # type: ignore[misc]
|
|
total=False,
|
|
)
|
|
|
|
|
|
class UserSchema(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
username: str
|
|
email: str | None
|
|
enabled: bool
|
|
role: Role
|
|
oauth_scopes: list[str]
|
|
avatar_path: str
|
|
last_login: UTCDatetime | None
|
|
last_active: UTCDatetime | None
|
|
ra_username: str | None = None
|
|
ra_progression: RAProgression | None = None
|
|
ui_settings: dict | None = None
|
|
current_device_id: str | None = None
|
|
|
|
created_at: UTCDatetime
|
|
updated_at: UTCDatetime
|
|
|
|
@classmethod
|
|
def from_orm_with_request(
|
|
cls, db_user: User | None, request: Request
|
|
) -> "UserSchema | None":
|
|
if not db_user:
|
|
return None
|
|
|
|
schema = cls.model_validate(db_user)
|
|
schema.current_device_id = request.session.get("device_id")
|
|
return schema
|
|
|
|
|
|
class InviteLinkSchema(BaseModel):
|
|
token: str
|