From 30e4de6767aeaecb5e30fa81fc0217f1778facdb Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Fri, 15 Nov 2013 16:39:17 -0500 Subject: [PATCH] Freshdesk: fix erroring on unknown statuses by hardcoding FlightCar's. (imported from commit 0a4b8ccaa883048fdc7a7d7712cc528194775d89) --- zerver/views/webhooks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zerver/views/webhooks.py b/zerver/views/webhooks.py index 95949c1477..809713218d 100644 --- a/zerver/views/webhooks.py +++ b/zerver/views/webhooks.py @@ -594,14 +594,19 @@ class TicketDict(dict): return self.get("ticket_" + field) def property_name(property, index): + # The Freshdesk API is currently pretty broken: statuses are customizable + # but the API will only tell you the number associated with the status, not + # the name. While we engage the Freshdesk developers about exposing this + # information through the API, since only FlightCar uses this integration, + # hardcode their statuses. statuses = ["", "", "Open", "Pending", "Resolved", "Closed", - "Waiting on Customer", "Waiting on Third Party"] + "Waiting on Customer", "Job Application", "Monthly"] priorities = ["", "Low", "Medium", "High", "Urgent"] if property == "status": - return statuses[index] + return statuses[index] if index < len(statuses) else str(index) elif property == "priority": - return priorities[index] + return priorities[index] if index < len(priorities) else str(index) else: raise ValueError("Unknown property")