The Conversations page calls aimsight-libredesk's conversations/pulling.py (formerly pompage.py, renamed with that repository's English translation); docs follow (pull.sh, pulling.py)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f0470295fa
commit
cccdeae67e
5 files changed
+15
-15
No files matched your search
+3
-3
@@ -415,15 +415,15 @@ def check_conversations():
|
||||
assert "img-src 'self'" in server.conversation_transcript("42").headers["content-security-policy"]
|
||||
refuses(conversations.transcript, "../analyses", False)
|
||||
refuses(server.conversation_file, "42", "../../etc/passwd")
|
||||
if conversations.pompage: # ~/aimsight-libredesk may be on a branch without conversations/ yet
|
||||
if conversations.pulling: # ~/aimsight-libredesk may be on a branch without conversations/ yet
|
||||
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
|
||||
pulling, conversations.pulling = conversations.pulling, 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
|
||||
conversations.pulling = pulling
|
||||
finally:
|
||||
conversations.FOLDER = before
|
||||
shutil.rmtree(root)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""The Conversations page: the LibreDesk conversations, pumped read-only by ~/aimsight-libredesk (link libredesk/,
|
||||
conversations/pompage.py, called as it is; its key stays in its .env) into labeling/auto/conversations/<reference>/
|
||||
conversations/pulling.py, called as it is; its key stays in its .env) into labeling/auto/conversations/<reference>/
|
||||
(conversation.json, messages.json, attachments/, transcript.md). The app lists them and shows a transcript safely: the text
|
||||
escaped before Markdown (a client's <script> stays text), served with a strict CSP (no script, no remote image), the
|
||||
attachments other than plain images as downloads.
|
||||
@@ -15,25 +15,25 @@ FOLDER = station.LABELS / "auto" / "conversations"
|
||||
LIBREDESK = station.ROOT / "libredesk"
|
||||
sys.path.append(str(LIBREDESK / "conversations"))
|
||||
try:
|
||||
import pompage # noqa: E402
|
||||
import pulling # noqa: E402
|
||||
except ImportError: # the page is not core: without the link, the rest of the app runs
|
||||
pompage = None
|
||||
pulling = 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:
|
||||
if not pulling:
|
||||
return {"running": False, "log": [MISSING]}
|
||||
return {"running": pompage.running(), "log": pompage.log()}
|
||||
return {"running": pulling.running(), "log": pulling.log()}
|
||||
|
||||
|
||||
def pump(body):
|
||||
if not pompage:
|
||||
if not pulling:
|
||||
raise station.Refusal(MISSING)
|
||||
try:
|
||||
pompage.start(body.get("start") or "", body.get("end") or "", str(FOLDER))
|
||||
pulling.start(body.get("start") or "", body.get("end") or "", str(FOLDER))
|
||||
except ValueError as e:
|
||||
raise station.Refusal(str(e)) from e
|
||||
return pump_state()
|
||||
|
||||
Reference in new issue
Block a user