fix(api): default destination_email for legacy UI payloads

Accept account creates without destination_email (defaults to BizDocs
inbox) and force admin-ui rebuild on deploy so web container picks up UI changes.
This commit is contained in:
1sonhador committed 2026-07-01 01:36:07 +01:00
1 parent eb4a95dfc2
commit 210bc7e324
2 files changed
+20 -3

No files matched your search

+4 -3
View File
@@ -31,14 +31,15 @@ if [ ! -f .env ]; then
exit 1
fi
log "Building containers"
$COMPOSE build
log "Building containers (web forced rebuild for admin-ui)"
$COMPOSE build api worker deploy-hook
$COMPOSE build --no-cache web
log "Running migrations"
$COMPOSE run --rm migrate
log "Starting stack"
$COMPOSE up -d
$COMPOSE up -d --force-recreate api web worker deploy-hook
log "Health check"
curl -sf --max-time 10 http://127.0.0.1:8000/api/health >/dev/null
+16
View File
@@ -4,6 +4,8 @@ from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, computed_field, model_validator
DEFAULT_BIZDOCS_DESTINATION = "[email protected]"
class AccountBase(BaseModel):
name: str
@@ -24,6 +26,7 @@ class AccountBase(BaseModel):
class AccountCreate(AccountBase):
model_config = ConfigDict(extra="ignore")
destination_email: str = Field(default=DEFAULT_BIZDOCS_DESTINATION)
imap_password: str
smtp_password: str
# UI compat fields — ignored but accepted without validation error
@@ -32,6 +35,19 @@ class AccountCreate(AccountBase):
bizdocs_api_key: str | None = None
bizdocs_entity_id: str | None = None
@model_validator(mode="before")
@classmethod
def _apply_ui_compat_defaults(cls, data: object) -> object:
if not isinstance(data, dict):
return data
if not data.get("destination_email"):
data["destination_email"] = DEFAULT_BIZDOCS_DESTINATION
if not data.get("imap_user") and data.get("email"):
data["imap_user"] = data["email"]
if not data.get("smtp_user") and data.get("email"):
data["smtp_user"] = data["email"]
return data
@model_validator(mode="after")
def _sync_active(self) -> AccountCreate:
if self.active is not None: