mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
feat(backend): Add legacy token handling in NotionHistoryConnector and log warnings for legacy usage in indexing
This commit is contained in:
parent
b3f553802c
commit
c6d25ed7d8
2 changed files with 72 additions and 9 deletions
|
|
@ -176,6 +176,13 @@ async def index_notion_pages(
|
|||
logger.info(
|
||||
f"{pages_with_skipped_content} pages had Notion AI content skipped (not available via API)"
|
||||
)
|
||||
|
||||
# Check if using legacy integration token and log warning
|
||||
if notion_client.is_using_legacy_token():
|
||||
logger.warning(
|
||||
f"Connector {connector_id} is using legacy integration token. "
|
||||
"Recommend reconnecting with OAuth."
|
||||
)
|
||||
except Exception as e:
|
||||
await task_logger.log_task_failure(
|
||||
log_entry,
|
||||
|
|
@ -471,8 +478,8 @@ async def index_notion_pages(
|
|||
# Add user-friendly message about skipped Notion AI content
|
||||
if pages_with_skipped_ai_content > 0:
|
||||
result_message += (
|
||||
f" Audio transcriptions and AI summaries from Notion aren't accessible "
|
||||
f"via their API — all other content was saved."
|
||||
" Audio transcriptions and AI summaries from Notion aren't accessible "
|
||||
"via their API - all other content was saved."
|
||||
)
|
||||
|
||||
# Log success
|
||||
|
|
@ -496,18 +503,26 @@ async def index_notion_pages(
|
|||
# Clean up the async client
|
||||
await notion_client.close()
|
||||
|
||||
# Return user-friendly message about skipped AI content (if any)
|
||||
# Build user-friendly notification messages
|
||||
# This will be shown in the notification to inform users
|
||||
user_notification_message = None
|
||||
notification_parts = []
|
||||
|
||||
if pages_with_skipped_ai_content > 0:
|
||||
user_notification_message = (
|
||||
"Some Notion AI content couldn't be synced (Notion API limitation)"
|
||||
notification_parts.append(
|
||||
"Some Notion AI content couldn't be synced (API limitation)"
|
||||
)
|
||||
|
||||
if notion_client.is_using_legacy_token():
|
||||
notification_parts.append(
|
||||
"Using legacy token. Reconnect with OAuth for better reliability."
|
||||
)
|
||||
|
||||
user_notification_message = " ".join(notification_parts) if notification_parts else None
|
||||
|
||||
return (
|
||||
total_processed,
|
||||
user_notification_message,
|
||||
) # Return message about skipped AI content if any
|
||||
)
|
||||
|
||||
except SQLAlchemyError as db_error:
|
||||
await session.rollback()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue