From 4ca89b6ffeefae201bb170f2f3ab8ddc7dbd3774 Mon Sep 17 00:00:00 2001 From: appleb_m Date: Thu, 4 Dec 2025 11:30:36 +0100 Subject: [PATCH] Server: correctly masks status in a cleaner manner --- daq/src/aaredaq/server.py | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/daq/src/aaredaq/server.py b/daq/src/aaredaq/server.py index a53f79bb..7ea166a7 100644 --- a/daq/src/aaredaq/server.py +++ b/daq/src/aaredaq/server.py @@ -62,29 +62,17 @@ async def status(token: str = Depends(oauth2_scheme)) -> DAQStatusModel: sample_pgroup = full.sample.user if full.sample is not None else None sample_view_allowed = sample_pgroup in data.pgroups or is_staff - masked_sample = full.sample if in_ro and sample_view_allowed else None - masked_box = full.box if in_ro else None - masked_best_res = full.last_best_res if in_ro else None - masked_best_b = full.last_best_b_factor if in_ro else None - masked_crystal = full.crystal_size if in_ro else CrystalSize(x=0,y=0,z=0) - - return DAQStatusModel( - state=full.state, - busy=full.busy, - geom=full.geom, - diffraction=full.diffraction, - bl=full.bl, - sample=masked_sample, - session=SessionStatus( + full.sample = full.sample if in_ro and sample_view_allowed else None + full.box = full.box if in_ro else None + full.last_best_res = full.last_best_res if in_ro else None + full.last_best_b_factor = full.last_best_b_factor if in_ro else None + full.crystal_size = full.crystal_size if in_ro else CrystalSize(x=0,y=0,z=0) + full.session = SessionStatus( current_pgroup=cfg.pgroup, session=cfg.session_state(data.session), staff=data.staff - ), - box=masked_box, - last_best_res=masked_best_res, - last_best_b_factor=masked_best_b, - crystal_size=masked_crystal ) + return full except Exception as e: logger.error(f"Error getting status: {e}") @@ -424,10 +412,10 @@ async def auto(s: SampleShortInfo, token: str = Depends(oauth2_scheme)): @app.post("/scan/smart_params") async def set_smart_params(p: SimpleScanParameters, token: str = Depends(oauth2_scheme)) -> str: - token_data = auth.parse_token(token) - logger.debug(f"{token_data.session} Try to set smart params: {p}") + #token_data = auth.parse_token(token) + #logger.debug(f"{token_data.session} Try to set smart params: {p}") auth.check_jwt_rw(cfg, auth.parse_token(token)) - daq.smart_params = p + cfg.auto_params = p return "OK" @app.post("/scan/cancel")