mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 02:46:25 +02:00
refactor: streamline authentication expiration handling in Notion tool metadata service
This commit is contained in:
parent
10af5d3f3e
commit
f4da05d0ea
1 changed files with 11 additions and 8 deletions
|
|
@ -167,17 +167,20 @@ class NotionToolMetadataService:
|
||||||
if not page_id:
|
if not page_id:
|
||||||
return {"error": "Page ID not found in document metadata"}
|
return {"error": "Page ID not found in document metadata"}
|
||||||
|
|
||||||
|
current_title = document.title
|
||||||
|
document_id = document.id
|
||||||
|
indexed_at = document.document_metadata.get("indexed_at")
|
||||||
|
|
||||||
acc_dict = account.to_dict()
|
acc_dict = account.to_dict()
|
||||||
auth_expired = await self._check_account_health(connector.id)
|
auth_expired = await self._check_account_health(connector.id)
|
||||||
acc_dict["auth_expired"] = auth_expired
|
acc_dict["auth_expired"] = auth_expired
|
||||||
if auth_expired:
|
if auth_expired:
|
||||||
try:
|
try:
|
||||||
db_connector = connector
|
if not connector.config.get("auth_expired"):
|
||||||
if not db_connector.config.get("auth_expired"):
|
connector.config = {**connector.config, "auth_expired": True}
|
||||||
db_connector.config = {**db_connector.config, "auth_expired": True}
|
flag_modified(connector, "config")
|
||||||
flag_modified(db_connector, "config")
|
|
||||||
await self._db_session.commit()
|
await self._db_session.commit()
|
||||||
await self._db_session.refresh(db_connector)
|
await self._db_session.refresh(connector)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Failed to persist auth_expired for connector %s",
|
"Failed to persist auth_expired for connector %s",
|
||||||
|
|
@ -188,9 +191,9 @@ class NotionToolMetadataService:
|
||||||
return {
|
return {
|
||||||
"account": acc_dict,
|
"account": acc_dict,
|
||||||
"page_id": page_id,
|
"page_id": page_id,
|
||||||
"current_title": document.title,
|
"current_title": current_title,
|
||||||
"document_id": document.id,
|
"document_id": document_id,
|
||||||
"indexed_at": document.document_metadata.get("indexed_at"),
|
"indexed_at": indexed_at,
|
||||||
}
|
}
|
||||||
|
|
||||||
async def get_delete_context(
|
async def get_delete_context(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue