app/: the Support page reads client mails from LibreDesk (read-only)

Menu « Depuis LibreDesk » : the 50 latest conversations; choosing one fills the
mail (thread newest first, no private notes, decoded subjects) and its images
over 10 kB. Settings LIBREDESK_* in API/.env; check_libredesk in check.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-05 16:30:38 +01:00
1 parent 67a1d71c57
commit b475da0acc
6 files changed
+148 -4

No files matched your search

+29 -1
View File
@@ -109,7 +109,35 @@ def check_station():
station.ETIQUETTES = avant
CHECKS = [check_serveur, check_station]
def check_libredesk():
# le fil et ses images depuis de fausses réponses de l'API : ordre, notes privées, logos écartés
import base64
import libredesk
png = b"\x89PNG" + b"x" * libredesk.TAILLE_MIN
msgs = [{"created_at": "2026-11-04T08:00Z", "type": "incoming", "private": False, "text_content": "Bonjour, trou ?",
"author": {"first_name": "David", "email": "d@x.ch"}, "meta": {"subject": "Crissier"},
"attachments": [{"name": "c.png", "content_type": "image/png", "size": len(png), "url": "/uploads/a"},
{"name": "logo.png", "content_type": "image/png", "size": 900, "url": "/uploads/b"}]},
{"created_at": "2026-11-04T09:00Z", "type": "outgoing", "private": True, "text_content": "note interne"},
{"created_at": "2026-11-05T08:00Z", "type": "outgoing", "private": False, "text_content": "Hello David",
"author": {"first_name": "Marc"}}]
avant = libredesk._requete
libredesk._requete = lambda c: json.dumps({"data": {"results": msgs}}).encode() if "/messages" in c else png
try:
c = libredesk.conversation("0b1c-2d")
finally:
libredesk._requete = avant
assert c["mail"].index("Hello David") < c["mail"].index("Bonjour, trou ?") and "note interne" not in c["mail"], c["mail"]
assert "De: David <d@x.ch>" in c["mail"] and "Objet: Crissier" in c["mail"], c["mail"]
assert [i["nom"] for i in c["images"]] == ["c.png"] and base64.b64decode(c["images"][0]["base64"]) == png
try:
libredesk.conversation("../x")
raise AssertionError("uuid ../x accepté")
except ValueError:
pass
CHECKS = [check_serveur, check_station, check_libredesk]
if __name__ == "__main__":
nom = sys.argv[1] if len(sys.argv) > 1 else None