fix(ovhcloud): find the call queue under either product (1.2.2)
A queue reached 404 "This service does not exist" on an account where the number was plainly configured as one. The number was right: the PRODUCT was wrong. OVH files a call queue under easyHunting or under ovhPabx depending on the offer the number carries, the hunting routes underneath are identical either way, and the control panel says "File d'appels" for both — so there is nothing an operator can look at to tell which one they have. It is now discovered once per run rather than assumed, and a service found under neither product says which names DO exist under each. That turns the least helpful error this API produces — one that reads as a wrong number — into a list somebody can copy the right value out of. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TN1R4EnNFUV2Xwtd9q98tj
This commit is contained in:
@@ -166,9 +166,40 @@ def _telephony(cfg):
|
||||
return ba, service
|
||||
|
||||
|
||||
# The call queue lives under ONE OF TWO PRODUCTS, and which one is not something an
|
||||
# operator can see: the control panel says "File d'appels" for both. OVH files them
|
||||
# under easyHunting or under ovhPabx depending on the offer the number carries, and
|
||||
# the hunting routes underneath are identical either way.
|
||||
#
|
||||
# Assuming easyHunting is what this did first, and the symptom was a 404 reading
|
||||
# "This service does not exist" — which sounds like a wrong number and is in fact a
|
||||
# wrong product. So it is DISCOVERED, once per process, and a failure says what does
|
||||
# exist rather than what does not.
|
||||
_PRODUCTS = ("easyHunting", "ovhPabx")
|
||||
|
||||
|
||||
def _product(cfg):
|
||||
if _CACHE.get("product"):
|
||||
return _CACHE["product"]
|
||||
ba, service = _telephony(cfg)
|
||||
found = {}
|
||||
for product in _PRODUCTS:
|
||||
names = request("GET", "/telephony/" + urllib.parse.quote(ba, safe="") + "/" + product, cfg) or []
|
||||
found[product] = [str(n) for n in names]
|
||||
if service in found[product]:
|
||||
_CACHE["product"] = product
|
||||
return product
|
||||
raise Exception(
|
||||
"no call queue named %s on %s. easyHunting holds [%s]; ovhPabx holds [%s]. "
|
||||
"Set telephony_service to one of those names, or configure the number as a "
|
||||
"call queue in the control panel first."
|
||||
% (service, ba, ", ".join(found.get("easyHunting") or ["-"]), ", ".join(found.get("ovhPabx") or ["-"])))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
ba, service = _telephony(cfg)
|
||||
return "/telephony/" + urllib.parse.quote(ba, safe="") + "/easyHunting/" + urllib.parse.quote(service, safe="")
|
||||
return ("/telephony/" + urllib.parse.quote(ba, safe="") + "/" + _product(cfg) +
|
||||
"/" + urllib.parse.quote(service, safe=""))
|
||||
|
||||
|
||||
def _queue_id(cfg):
|
||||
@@ -212,15 +243,16 @@ def main(cfg, inputs):
|
||||
service = str(cfg.get("telephony_service") or "").strip()
|
||||
scheme = "service account" if _oauth(cfg) else "application key"
|
||||
if ba and service:
|
||||
product = _product(cfg)
|
||||
queues = request("GET", _base(cfg) + "/hunting/queue", cfg)
|
||||
if not isinstance(queues, list) or not queues:
|
||||
# Reached the API and found the service, but it holds no queue. NOT a
|
||||
# failure of the credentials, and saying so plainly is the difference
|
||||
# between "go and create a queue" and an evening spent on authentication.
|
||||
return {"ok": True, "auth": scheme, "telephony": True, "queues": 0,
|
||||
return {"ok": True, "auth": scheme, "telephony": True, "product": product, "queues": 0,
|
||||
"detail": "Authenticated, and the service was found, but it holds no call queue yet. "
|
||||
"Create one in the control panel before publishing an on-call ladder."}
|
||||
return {"ok": True, "auth": scheme, "telephony": True,
|
||||
return {"ok": True, "auth": scheme, "telephony": True, "product": product,
|
||||
"queues": len(queues), "queue_ids": [str(q) for q in queues]}
|
||||
resp = request("GET", "/me", cfg)
|
||||
return {"ok": True, "auth": scheme, "nichandle": resp.get("nichandle")}
|
||||
|
||||
Reference in New Issue
Block a user