Allowing to update smallwebrtc and whatsapp properties.

This commit is contained in:
Filipi Fuchter
2025-10-07 17:28:14 -03:00
parent 250cf2d8f1
commit da4f30cb6d
3 changed files with 28 additions and 0 deletions

View File

@@ -116,6 +116,10 @@ class SmallWebRTCRequestHandler:
detail="Cannot create new connection with existing connection active",
)
def update_ice_servers(self, ice_servers: Optional[List[IceServer]] = None):
"""Update the list of ICE servers used for WebRTC connections."""
self._ice_servers = ice_servers
async def handle_web_request(
self,
request: SmallWebRTCRequest,

View File

@@ -241,6 +241,14 @@ class WhatsAppApi:
self._whatsapp_url = f"{self.BASE_URL}{phone_number_id}/calls"
self._whatsapp_token = whatsapp_token
def update_whatsapp_token(self, whatsapp_token: str):
"""Update the WhatsApp access token for authentication."""
self._whatsapp_token = whatsapp_token
def update_whatsapp_phone_number_id(self, phone_number_id: str):
"""Update the WhatsApp phone number ID for authentication."""
self._phone_number_id = phone_number_id
async def answer_call_to_whatsapp(self, call_id: str, action: str, sdp: str, from_: str):
"""Answer an incoming WhatsApp call.

View File

@@ -73,6 +73,22 @@ class WhatsAppClient:
else:
self._ice_servers = ice_servers
def update_ice_servers(self, ice_servers: Optional[List[IceServer]] = None):
"""Update the list of ICE servers used for WebRTC connections."""
self._ice_servers = ice_servers
def update_whatsapp_secret(self, whatsapp_secret: Optional[str] = None):
"""Update the WhatsApp APP secret for validating that the webhook request came from WhatsApp."""
self._whatsapp_secret = whatsapp_secret
def update_whatsapp_token(self, whatsapp_token: str):
"""Update the WhatsApp API access token."""
self._whatsapp_api.update_whatsapp_token(whatsapp_token)
def update_whatsapp_phone_number_id(self, phone_number_id: str):
"""Update the WhatsApp phone number ID for authentication."""
self._whatsapp_api.update_whatsapp_phone_number_id(phone_number_id)
async def terminate_all_calls(self) -> None:
"""Terminate all ongoing WhatsApp calls.