fix(photon): use per-user assigned line for agent iMessage number
On shared-number plans, `/lines` has no dedicated entry, so the `assignedPhoneNumber` field on the user object is the source of truth for which number to text the agent. Fall back to the line inventory only when no per-user assignment exists.
This commit is contained in:
committed by
Teknium
parent
314af28e86
commit
84e4b4b9a5
@@ -751,6 +751,21 @@ def register_user_if_absent(
|
||||
return user, True
|
||||
|
||||
|
||||
def user_assigned_line(user: Optional[Dict[str, Any]]) -> Optional[str]:
|
||||
"""Return the iMessage number a Spectrum user is assigned to text on.
|
||||
|
||||
This is the user's ``assignedPhoneNumber`` (the dashboard's "TEXTS ON"
|
||||
column) — i.e. the number to text to reach the agent, as opposed to the
|
||||
user's own ``phoneNumber``. On shared-number plans there is no dedicated
|
||||
entry in ``/lines``, so this per-user field is the source of truth.
|
||||
Returns ``None`` when unset (e.g. a freshly created, not-yet-assigned user).
|
||||
"""
|
||||
if not user:
|
||||
return None
|
||||
val = user.get("assignedPhoneNumber")
|
||||
return str(val) if val else None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Dashboard API: iMessage lines (the assigned number inventory)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user