mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 02:46:25 +02:00
feat: enhance OneDrive file creation tool by adding parent folder selection and handling expired accounts
This commit is contained in:
parent
c325f53941
commit
5d467cdfc2
2 changed files with 160 additions and 30 deletions
|
|
@ -109,7 +109,32 @@ def create_create_onedrive_file_tool(
|
|||
"connector_type": "onedrive",
|
||||
}
|
||||
|
||||
context = {"accounts": accounts}
|
||||
parent_folders: dict[int, list[dict[str, str]]] = {}
|
||||
for acc in accounts:
|
||||
cid = acc["id"]
|
||||
if acc.get("auth_expired"):
|
||||
parent_folders[cid] = []
|
||||
continue
|
||||
try:
|
||||
client = OneDriveClient(session=db_session, connector_id=cid)
|
||||
items, err = await client.list_children("root")
|
||||
if err:
|
||||
logger.warning("Failed to list folders for connector %s: %s", cid, err)
|
||||
parent_folders[cid] = []
|
||||
else:
|
||||
parent_folders[cid] = [
|
||||
{"folder_id": item["id"], "name": item["name"]}
|
||||
for item in items
|
||||
if item.get("folder") is not None and item.get("id") and item.get("name")
|
||||
]
|
||||
except Exception:
|
||||
logger.warning("Error fetching folders for connector %s", cid, exc_info=True)
|
||||
parent_folders[cid] = []
|
||||
|
||||
context: dict[str, Any] = {
|
||||
"accounts": accounts,
|
||||
"parent_folders": parent_folders,
|
||||
}
|
||||
|
||||
approval = interrupt(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue