From a44c5361f40941225f9ec7f783d68af7b56f9e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Wed, 15 May 2024 11:49:06 +0200 Subject: [PATCH] [fs2zammad] extra tweaks for zammad to accept edge cases/tickets --- fs2zammad | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fs2zammad b/fs2zammad index 15be118..30963b5 100755 --- a/fs2zammad +++ b/fs2zammad @@ -70,15 +70,25 @@ def maybe_create_zammad_user(userdata, zammad_session, attr="login", default=Non else: raise ValueError("Invalid userdata") + # We manually filter out invalid addresses. + if email == "*@*.com": + userdata = { + 'EmailAddress': 'technik@ungleich.ch', + 'RealName': 'Disabled RT' + } + email = userdata["EmailAddress"] + + lowercase_email = email.lower() + if lowercase_email not in USERMAP: kwargs = {"email": email} kwargs.update(config["userdata"]) if "RealName" in userdata: realname = userdata["RealName"] - if ", " in realname: + if ", " in realname.strip(): last, first = realname.split(", ", 1) - elif " " in realname: + elif " " in realname.strip(): first, last = realname.split(None, 1) else: last = realname @@ -217,6 +227,8 @@ def create_zammad_ticket(id, zammad, h2t, retries=3): entry_content = base64.b64decode(file["data"]).decode("utf-8") if file["mime-type"]: entry_content = h2t.handle(entry_content) + if entry_content.strip() == '': + entry_content = "RT: Empty content." zammad_entry_template = { "ticket_id": zammad_ticket["id"],