Implement tracker update webhook

master
Drew DeVault 2020-04-02 10:13:01 -04:00
parent 8f015eb153
commit fc586256cb
1 changed files with 9 additions and 1 deletions

View File

@ -55,7 +55,15 @@ def tracker():
event = request.headers.get("X-Webhook-Event")
payload = json.loads(request.data.decode("utf-8"))
if event == "tracker:update":
raise NotImplementedError()
tracker = (Tracker.query
.filter(Tracker.remote_id == payload["id"])
.one_or_none())
if not tracker:
return "I don't recognize this tracker.", 404
tracker.name = payload["name"]
tracker.description = payload["description"]
db.session.commit()
return f"Updated local:{tracker.id}/remote:{tracker.remote_id}. Thanks!", 200
elif event == "tracker:delete":
raise NotImplementedError()
elif event == "ticket:create":