Added form_category to the ticket payload if existing

This resolves #203.
This commit is contained in:
Psycho 2026-05-05 23:11:28 +02:00
parent 16b3366cb0
commit 175bb24653

View file

@ -345,28 +345,33 @@ try:
assert isinstance(customer_id, (str, int)) assert isinstance(customer_id, (str, int))
# Add the actual ticket to the system. # 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( response = session.post(
urljoin(ZAMMAD_URL, "api/v1/tickets"), urljoin(ZAMMAD_URL, "api/v1/tickets"),
headers={ headers={
"From": contact_email, "From": contact_email,
}, },
json=dict( json=ticket_payload,
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",
}],
),
),
) )
response.raise_for_status() response.raise_for_status()
ticket_id = response.json()["id"] ticket_id = response.json()["id"]