From 175bb2465397ff8745b88dc5b465c6a288d9589e Mon Sep 17 00:00:00 2001 From: Psycho Date: Tue, 5 May 2026 23:11:28 +0200 Subject: [PATCH] Added form_category to the ticket payload if existing This resolves #203. --- cgi-bin/form.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/cgi-bin/form.py b/cgi-bin/form.py index a6ab437..c707fea 100755 --- a/cgi-bin/form.py +++ b/cgi-bin/form.py @@ -345,28 +345,33 @@ try: assert isinstance(customer_id, (str, int)) # Add the actual ticket to the system. + + ticket_payload=dict( + title=f"Kontaktformular {contact_name} – {form_name}", + group=form_group, + customer_id=customer_id, + article=dict( + type="web", + internal=True, + content_type="text/plain", + subject=f"Kontaktformular-Anfrage {contact_name}", + body=message, + attachments=[] if attachment is None else [{ + "filename": attachment[0], + "data": base64.b64encode(attachment[1]).decode(), + "mime-type": mimetypes.guess_type(attachment[0])[0] or "text/plain", + }], + ), + ) + if form_category: + ticket_payload["category"] = form_category + response = session.post( urljoin(ZAMMAD_URL, "api/v1/tickets"), headers={ "From": contact_email, }, - json=dict( - title=f"Kontaktformular {contact_name} – {form_name}", - group=form_group, - customer_id=customer_id, - article=dict( - type="web", - internal=True, - content_type="text/plain", - subject=f"Kontaktformular-Anfrage {contact_name}", - body=message, - attachments=[] if attachment is None else [{ - "filename": attachment[0], - "data": base64.b64encode(attachment[1]).decode(), - "mime-type": mimetypes.guess_type(attachment[0])[0] or "text/plain", - }], - ), - ), + json=ticket_payload, ) response.raise_for_status() ticket_id = response.json()["id"]