diff --git a/surfsense_backend/app/connectors/google_calendar_connector.py b/surfsense_backend/app/connectors/google_calendar_connector.py index 38a7ae1..2f8846c 100644 --- a/surfsense_backend/app/connectors/google_calendar_connector.py +++ b/surfsense_backend/app/connectors/google_calendar_connector.py @@ -79,7 +79,7 @@ class GoogleCalendarConnector: ) # Refresh the token if needed - if self._credentials.expired: + if self._credentials.expired or not self._credentials.valid: try: self._credentials.refresh(Request()) # Update the connector config in DB diff --git a/surfsense_backend/app/connectors/google_gmail_connector.py b/surfsense_backend/app/connectors/google_gmail_connector.py index f51f4c1..d012ade 100644 --- a/surfsense_backend/app/connectors/google_gmail_connector.py +++ b/surfsense_backend/app/connectors/google_gmail_connector.py @@ -78,7 +78,7 @@ class GoogleGmailConnector: ) # Refresh the token if needed - if self._credentials.expired: + if self._credentials.expired or not self._credentials.valid: try: self._credentials.refresh(Request()) # Update the connector config in DB diff --git a/surfsense_backend/app/tasks/connector_indexers/base.py b/surfsense_backend/app/tasks/connector_indexers/base.py index fb639f9..28cd206 100644 --- a/surfsense_backend/app/tasks/connector_indexers/base.py +++ b/surfsense_backend/app/tasks/connector_indexers/base.py @@ -60,27 +60,6 @@ async def get_connector_by_id( return result.scalars().first() -async def get_connector_by_type( - session: AsyncSession, connector_type: SearchSourceConnectorType -) -> SearchSourceConnector | None: - """ - Get a connector by type from the database. - - Args: - session: Database session - connector_type: Type of the connector - - Returns: - Connector object if found, None otherwise - """ - result = await session.execute( - select(SearchSourceConnector).filter( - SearchSourceConnector.connector_type == connector_type, - ) - ) - return result.scalars().first() - - def calculate_date_range( connector: SearchSourceConnector, start_date: str | None = None,