From ccd6af7016424b39fb949a8f4326ec1174b3c7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Wed, 12 Jun 2024 23:15:22 -0700 Subject: [PATCH] transports(helpers): fix DailyRoomProperties.exp --- CHANGELOG.md | 3 +++ .../transports/services/helpers/daily_rest.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da1d9e9ba..e5f953635 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed an issue where `DailyRoomProperties.exp` always had the same old + timestamp unless set by the user. + - Fixed a couple of issues with `WebsocketServerTransport`. It needed to use `push_audio_frame()` and also VAD was not working properly. diff --git a/src/pipecat/transports/services/helpers/daily_rest.py b/src/pipecat/transports/services/helpers/daily_rest.py index 35786f62b..04e2cffc7 100644 --- a/src/pipecat/transports/services/helpers/daily_rest.py +++ b/src/pipecat/transports/services/helpers/daily_rest.py @@ -10,12 +10,14 @@ Daily REST Helpers Methods that wrap the Daily API to create rooms, check room URLs, and get meeting tokens. """ -from urllib.parse import urlparse -import requests -from typing import Literal, Optional -from time import time -from pydantic import BaseModel, ValidationError +import requests +import time + +from urllib.parse import urlparse + +from pydantic import Field, BaseModel, ValidationError +from typing import Literal, Optional class DailyRoomSipParams(BaseModel): @@ -26,7 +28,7 @@ class DailyRoomSipParams(BaseModel): class DailyRoomProperties(BaseModel, extra="allow"): - exp: float = time() + 5 * 60 + exp: float = Field(default_factory=lambda: time.time() + 5 * 60) enable_chat: bool = False enable_emoji_reactions: bool = False eject_at_room_exp: bool = True @@ -112,7 +114,7 @@ class DailyRESTHelper: raise Exception( "No Daily room specified. You must specify a Daily room in order a token to be generated.") - expiration: float = time() + expiry_time + expiration: float = time.time() + expiry_time room_name = self._get_name_from_url(room_url)