| 1 | """Hide the "Native client test" meeting chats that live call tests leave behind. |
| 2 | |
| 3 | Runs through the signed-in M365 web session (skill running-m365-web-session). |
| 4 | """ |
| 5 | import os |
| 6 | import sys |
| 7 | import urllib.parse |
| 8 | |
| 9 | sys.path.insert(0, os.path.expanduser("~/.claude/skills/running-m365-web-session")) |
| 10 | from m365web.client import Client |
| 11 | |
| 12 | SUBJECT = "Native client test" |
| 13 | GRAPH = "https://graph.microsoft.com/v1.0" |
| 14 | SCOPE = "Chat.ReadWrite" |
| 15 | |
| 16 | with Client() as client: |
| 17 | me = client.request("GET", f"{GRAPH}/me?$select=id", SCOPE) |
| 18 | organization = client.request("GET", f"{GRAPH}/organization?$select=id", SCOPE) |
| 19 | user = {"id": me["id"], "tenantId": organization["value"][0]["id"]} |
| 20 | url = f"{GRAPH}/me/chats?$select=id,topic&$filter=topic eq '{SUBJECT}'&$top=50" |
| 21 | chat_ids = [] |
| 22 | while url: |
| 23 | page = client.request("GET", url, SCOPE) |
| 24 | chat_ids += [chat["id"] for chat in page["value"] if chat.get("topic") == SUBJECT] |
| 25 | url = page.get("@odata.nextLink") |
| 26 | for chat_id in chat_ids: |
| 27 | path = urllib.parse.quote(chat_id, safe="") |
| 28 | client.request("POST", f"{GRAPH}/chats/{path}/hideForUser", SCOPE, body={"user": user}) |
| 29 | print(f"hid {len(chat_ids)} test meeting chat(s)") |