From bbc600b0b13736d21f162cc349e47f890ad918d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 30 Dec 2020 13:43:06 +0100 Subject: [PATCH] Retain ticket ownership --- rt2zammad.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/rt2zammad.py b/rt2zammad.py index eb70789..71739ae 100755 --- a/rt2zammad.py +++ b/rt2zammad.py @@ -208,18 +208,29 @@ for ticket in tickets: }, } + merged = False if ticket["ticket"]["original_id"] != ticket["ticket"]["numerical_id"]: # Merged ticket + merged = True create_args["state_id"] = 4 create_args["article"]["body"] = "RT ticket merged into {}".format( ticket["ticket"]["numerical_id"] ) - get_zammad(creator).ticket.create(create_args) - continue - create_args["state_id"] = STATUSMAP[ticket["ticket"]["Status"]] - create_args["article"]["body"] = ticket["history"][0]["Content"] - new = get_zammad(creator).ticket.create(create_args) + new = get_zammad(creator).ticket.create(create_args) + else: + create_args["state_id"] = STATUSMAP[ticket["ticket"]["Status"]] + create_args["article"]["body"] = ticket["history"][0]["Content"] + new = get_zammad(creator).ticket.create(create_args) + print(f"Created ticket {new['id']}") + + if ticket["ticket"]["Owner"] and ticket["ticket"]["Owner"] != "Nobody": + get_zammad().ticket.update(new['id'], {"owner_id": get_user(users[ticket["ticket"]["Owner"]], "id")}) + + if merged: + # Do not add comments to merged ticket + continue + tag_obj.add("Ticket", new["id"], ticket["ticket"]["Queue"].lower().split()[0]) ticket_article.create( {