diff --git a/app/server/check.py b/app/server/check.py index ffc5417..912de76 100644 --- a/app/server/check.py +++ b/app/server/check.py @@ -408,6 +408,12 @@ def check_conversations(): refuses(server.conversation_file, "42", "../../etc/passwd") assert "From and To" in refuses(conversations.pump, {"start": "2026-11-01"}) assert set(conversations.pump_state()) == {"running", "log"} + pompage, conversations.pompage = conversations.pompage, None # no libredesk/ link: the app still runs + try: + assert "libredesk/" in refuses(conversations.pump, {}) + assert conversations.pump_state()["running"] is False and "libredesk/" in conversations.pump_state()["log"][0] + finally: + conversations.pompage = pompage finally: conversations.FOLDER = before shutil.rmtree(root) diff --git a/app/server/conversations.py b/app/server/conversations.py index de508f5..eb1c8ce 100644 --- a/app/server/conversations.py +++ b/app/server/conversations.py @@ -13,17 +13,25 @@ import station FOLDER = station.LABELS / "auto" / "conversations" LIBREDESK = station.ROOT / "libredesk" -sys.path.insert(0, str(LIBREDESK / "conversations")) -import pompage # noqa: E402 +sys.path.append(str(LIBREDESK / "conversations")) +try: + import pompage # noqa: E402 +except ImportError: # the page is not core: without the link, the rest of the app runs + pompage = None +MISSING = "no libredesk/ link to ~/aimsight-libredesk with conversations/ (README)" INLINE = {".png", ".jpg", ".jpeg", ".gif", ".webp"} # shown in the page; any other attachment is downloaded def pump_state(): + if not pompage: + return {"running": False, "log": [MISSING]} return {"running": pompage.running(), "log": pompage.log()} def pump(body): + if not pompage: + raise station.Refusal(MISSING) try: pompage.start(body.get("start") or "", body.get("end") or "", str(FOLDER)) except ValueError as e: diff --git a/app/web/src/common.jsx b/app/web/src/common.jsx index 2df64b0..70674ce 100644 --- a/app/web/src/common.jsx +++ b/app/web/src/common.jsx @@ -36,9 +36,9 @@ export function Selector({ selection, choose }) { } // A markdown rendered by the server (report, summary, transcript), at the height of its content once its images are loaded; -// sandboxed: no script runs in it -export function Page({ title, src }) { +// sandboxed: no script runs in it (sandbox "allow-same-origin allow-downloads" where its links are attachments to save) +export function Page({ title, src, sandbox = "allow-same-origin" }) { const frame = useRef(); const fit = () => { const b = frame.current?.contentDocument?.body; if (b) frame.current.style.height = `${b.scrollHeight + 20}px`; }; - return