Spaces:
Sleeping
Sleeping
Download app/lib/graph/folder_resolver.py from cmoss3/RcmEmailAutomation: direct link, hf CLI and curl.
- Browser
- Download file 832 Bytes
-
https://huggingface.co/spaces/cmoss3/RcmEmailAutomation/resolve/main/app/lib/graph/folder_resolver.py
- Command line
-
hf download hf://spaces/cmoss3/RcmEmailAutomation/app/lib/graph/folder_resolver.py
-
curl -L -o folder_resolver.py https://huggingface.co/spaces/cmoss3/RcmEmailAutomation/resolve/main/app/lib/graph/folder_resolver.py
832 Bytes
| from app.lib.graph.client import GraphClient | |
| _BASE = "https://graph.microsoft.com/v1.0" | |
| async def resolve_folder_id(client: GraphClient, display_name: str, mailbox_user: str) -> str: | |
| path = f"/users/{mailbox_user}/mailFolders" | |
| params: dict = {"$top": 100} | |
| while path: | |
| data = await client.get(path, params=params) | |
| for folder in data.get("value", []): | |
| if folder["displayName"].lower() == display_name.lower(): | |
| return folder["id"] | |
| next_link: str | None = data.get("@odata.nextLink") | |
| if next_link: | |
| path = next_link.removeprefix(_BASE) | |
| params = {} | |
| else: | |
| break | |
| raise ValueError( | |
| f"Mail folder '{display_name}' not found. " | |
| f"Verify it exists as a top-level folder in the monitored mailbox." | |
| ) | |