Conversations: the app starts without the libredesk link; attachments downloadable from the transcript frame
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
45db86d1ff
commit
adc5ae12bd
4 files changed
+19
-5
No files matched your search
@@ -408,6 +408,12 @@ def check_conversations():
|
|||||||
refuses(server.conversation_file, "42", "../../etc/passwd")
|
refuses(server.conversation_file, "42", "../../etc/passwd")
|
||||||
assert "From and To" in refuses(conversations.pump, {"start": "2026-11-01"})
|
assert "From and To" in refuses(conversations.pump, {"start": "2026-11-01"})
|
||||||
assert set(conversations.pump_state()) == {"running", "log"}
|
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:
|
finally:
|
||||||
conversations.FOLDER = before
|
conversations.FOLDER = before
|
||||||
shutil.rmtree(root)
|
shutil.rmtree(root)
|
||||||
|
|||||||
@@ -13,17 +13,25 @@ import station
|
|||||||
|
|
||||||
FOLDER = station.LABELS / "auto" / "conversations"
|
FOLDER = station.LABELS / "auto" / "conversations"
|
||||||
LIBREDESK = station.ROOT / "libredesk"
|
LIBREDESK = station.ROOT / "libredesk"
|
||||||
sys.path.insert(0, str(LIBREDESK / "conversations"))
|
sys.path.append(str(LIBREDESK / "conversations"))
|
||||||
|
try:
|
||||||
import pompage # noqa: E402
|
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
|
INLINE = {".png", ".jpg", ".jpeg", ".gif", ".webp"} # shown in the page; any other attachment is downloaded
|
||||||
|
|
||||||
|
|
||||||
def pump_state():
|
def pump_state():
|
||||||
|
if not pompage:
|
||||||
|
return {"running": False, "log": [MISSING]}
|
||||||
return {"running": pompage.running(), "log": pompage.log()}
|
return {"running": pompage.running(), "log": pompage.log()}
|
||||||
|
|
||||||
|
|
||||||
def pump(body):
|
def pump(body):
|
||||||
|
if not pompage:
|
||||||
|
raise station.Refusal(MISSING)
|
||||||
try:
|
try:
|
||||||
pompage.start(body.get("start") or "", body.get("end") or "", str(FOLDER))
|
pompage.start(body.get("start") or "", body.get("end") or "", str(FOLDER))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
|||||||
@@ -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;
|
// 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
|
// sandboxed: no script runs in it (sandbox "allow-same-origin allow-downloads" where its links are attachments to save)
|
||||||
export function Page({ title, src }) {
|
export function Page({ title, src, sandbox = "allow-same-origin" }) {
|
||||||
const frame = useRef();
|
const frame = useRef();
|
||||||
const fit = () => { const b = frame.current?.contentDocument?.body; if (b) frame.current.style.height = `${b.scrollHeight + 20}px`; };
|
const fit = () => { const b = frame.current?.contentDocument?.body; if (b) frame.current.style.height = `${b.scrollHeight + 20}px`; };
|
||||||
return <iframe ref={frame} title={title} sandbox="allow-same-origin" onLoad={fit} style={{ border: 0, width: "100%", height: 400 }} src={src} />;
|
return <iframe ref={frame} title={title} sandbox={sandbox} onLoad={fit} style={{ border: 0, width: "100%", height: 400 }} src={src} />;
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ export default function Conversations() {
|
|||||||
</Card>
|
</Card>
|
||||||
{open && (
|
{open && (
|
||||||
<Card shadow="sm" withBorder>
|
<Card shadow="sm" withBorder>
|
||||||
<Page key={`${open}-${dark}`} title="Transcript" src={`/api/conversations/${encodeURIComponent(open)}/report.html?dark=${dark}`} />
|
<Page key={`${open}-${dark}`} title="Transcript" sandbox="allow-same-origin allow-downloads" src={`/api/conversations/${encodeURIComponent(open)}/report.html?dark=${dark}`} />
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in new issue
Block a user