mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-30 21:59:46 +02:00
feat: add authentication expiration handling for Notion tools
- Implemented checks for expired authentication in the Notion page creation and deletion tools, returning appropriate error messages for re-authentication. - Updated the Notion tool metadata service to track account health and persist authentication status, improving error handling and user feedback during operations.
This commit is contained in:
parent
db5fddb104
commit
10af5d3f3e
3 changed files with 42 additions and 2 deletions
|
|
@ -167,8 +167,26 @@ class NotionToolMetadataService:
|
|||
if not page_id:
|
||||
return {"error": "Page ID not found in document metadata"}
|
||||
|
||||
acc_dict = account.to_dict()
|
||||
auth_expired = await self._check_account_health(connector.id)
|
||||
acc_dict["auth_expired"] = auth_expired
|
||||
if auth_expired:
|
||||
try:
|
||||
db_connector = connector
|
||||
if not db_connector.config.get("auth_expired"):
|
||||
db_connector.config = {**db_connector.config, "auth_expired": True}
|
||||
flag_modified(db_connector, "config")
|
||||
await self._db_session.commit()
|
||||
await self._db_session.refresh(db_connector)
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"Failed to persist auth_expired for connector %s",
|
||||
connector.id,
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
return {
|
||||
"account": account.to_dict(),
|
||||
"account": acc_dict,
|
||||
"page_id": page_id,
|
||||
"current_title": document.title,
|
||||
"document_id": document.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue