mirror of
https://codeberg.org/angestoepselt/homepage.git
synced 2026-08-04 19:15:48 +00:00
Added form_category to the ticket payload if existing
This resolves #203.
This commit is contained in:
parent
16b3366cb0
commit
175bb24653
1 changed files with 22 additions and 17 deletions
|
|
@ -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"]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue