[fs2zammad] extra tweaks for zammad to accept edge cases/tickets
This commit is contained in:
parent
64218fe9d8
commit
a44c5361f4
1 changed files with 14 additions and 2 deletions
16
fs2zammad
16
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"],
|
||||
|
|
Loading…
Reference in a new issue