更新
This commit is contained in:
@@ -85,6 +85,18 @@ def _normalized_key(key: Any) -> str:
|
||||
return "".join(character for character in str(key).lower() if character.isalnum())
|
||||
|
||||
|
||||
def _appointment_id(value: Any) -> int:
|
||||
if value is None:
|
||||
return 0
|
||||
try:
|
||||
parsed = int(value)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise VideoTicketError("appointment_id must be a nonnegative integer") from exc
|
||||
if isinstance(value, bool) or parsed < 0 or str(value) != str(parsed):
|
||||
raise VideoTicketError("appointment_id must be a nonnegative integer")
|
||||
return parsed
|
||||
|
||||
|
||||
_FORBIDDEN_SECRET_KEYS = {"sdksecret", "sdksecretkey", "secretkey"}
|
||||
|
||||
|
||||
@@ -138,7 +150,8 @@ def _ticket_mapping(ticket: Any) -> Mapping[str, Any]:
|
||||
if hasattr(ticket, attribute_name)
|
||||
}
|
||||
if adapted:
|
||||
return adapted
|
||||
# Preserve server policy and identities; model attributes alone omit them.
|
||||
return {**(dict(raw) if isinstance(raw, Mapping) else {}), **adapted}
|
||||
raise VideoTicketError("backend ticket must be a mapping or call-ticket object")
|
||||
|
||||
|
||||
@@ -199,8 +212,15 @@ class VideoCallRequest:
|
||||
patient_id: Identifier | None = None
|
||||
call_record_id: Identifier | None = None
|
||||
backend_mode: BackendMode = BackendMode.EMBEDDED
|
||||
appointment_id: int = 0
|
||||
appointment_type: Any = None
|
||||
appointment_type_desc: str = ""
|
||||
can_video_call: bool = False
|
||||
can_audio_call: bool = False
|
||||
call_disabled_reason: str = ""
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
object.__setattr__(self, "appointment_id", _appointment_id(self.appointment_id))
|
||||
object.__setattr__(self, "sdk_app_id", _sdk_app_id(self.sdk_app_id))
|
||||
object.__setattr__(self, "user_id", _non_empty_string(self.user_id, "userID"))
|
||||
object.__setattr__(self, "user_sig", _non_empty_string(self.user_sig, "userSig"))
|
||||
@@ -257,6 +277,13 @@ class VideoCallRequest:
|
||||
"userSig": self.user_sig,
|
||||
"targetUserId": self.target_user_id,
|
||||
"diagnosisId": self.diagnosis_id,
|
||||
"patientId": self.patient_id,
|
||||
"appointmentId": self.appointment_id,
|
||||
"appointment_type": self.appointment_type,
|
||||
"appointment_type_desc": self.appointment_type_desc,
|
||||
"can_video_call": self.can_video_call is True,
|
||||
"can_audio_call": self.can_audio_call is True,
|
||||
"call_disabled_reason": self.call_disabled_reason,
|
||||
}
|
||||
|
||||
def safe_log_context(self) -> dict[str, Any]:
|
||||
@@ -340,6 +367,12 @@ def normalize_backend_ticket(
|
||||
diagnosis_id=normalized_diagnosis,
|
||||
patient_id=normalized_patient,
|
||||
call_record_id=payload_call_record,
|
||||
appointment_id=_appointment_id(payload.get("appointment_id", 0)),
|
||||
appointment_type=payload.get("appointment_type"),
|
||||
appointment_type_desc=str(payload.get("appointment_type_desc") or ""),
|
||||
can_video_call=payload.get("can_video_call") is True,
|
||||
can_audio_call=payload.get("can_audio_call") is True,
|
||||
call_disabled_reason=str(payload.get("call_disabled_reason") or ""),
|
||||
backend_mode=BackendMode.parse(backend_mode),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user