diff --git a/surfsense_backend/app/connectors/teams_connector.py b/surfsense_backend/app/connectors/teams_connector.py index 29c2db127..5603357e5 100644 --- a/surfsense_backend/app/connectors/teams_connector.py +++ b/surfsense_backend/app/connectors/teams_connector.py @@ -7,7 +7,7 @@ Supports OAuth-based authentication with token refresh. """ import logging -from datetime import datetime, timezone +from datetime import UTC, datetime from typing import Any import httpx @@ -275,9 +275,9 @@ class TeamsConnector: if start_date or end_date: # Make sure comparison dates are timezone-aware (UTC) if start_date and start_date.tzinfo is None: - start_date = start_date.replace(tzinfo=timezone.utc) + start_date = start_date.replace(tzinfo=UTC) if end_date and end_date.tzinfo is None: - end_date = end_date.replace(tzinfo=timezone.utc) + end_date = end_date.replace(tzinfo=UTC) filtered_messages = [] for message in messages: diff --git a/surfsense_backend/app/tasks/connector_indexers/teams_indexer.py b/surfsense_backend/app/tasks/connector_indexers/teams_indexer.py index c1e778768..3b28d4293 100644 --- a/surfsense_backend/app/tasks/connector_indexers/teams_indexer.py +++ b/surfsense_backend/app/tasks/connector_indexers/teams_indexer.py @@ -2,6 +2,8 @@ Microsoft Teams connector indexer. """ +from datetime import UTC + from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.ext.asyncio import AsyncSession @@ -165,16 +167,16 @@ async def index_teams_messages( ) # Convert date strings to datetime objects for filtering - from datetime import datetime, timezone + from datetime import datetime start_datetime = None end_datetime = None if start_date_str: # Parse as naive datetime and make it timezone-aware (UTC) - start_datetime = datetime.strptime(start_date_str, "%Y-%m-%d").replace(tzinfo=timezone.utc) + start_datetime = datetime.strptime(start_date_str, "%Y-%m-%d").replace(tzinfo=UTC) if end_date_str: # Parse as naive datetime, set to end of day, and make it timezone-aware (UTC) - end_datetime = datetime.strptime(end_date_str, "%Y-%m-%d").replace(hour=23, minute=59, second=59, tzinfo=timezone.utc) + end_datetime = datetime.strptime(end_date_str, "%Y-%m-%d").replace(hour=23, minute=59, second=59, tzinfo=UTC) # Process each team for team in teams: