diff --git a/maubot.yaml b/maubot.yaml index 9a9c80e..caa892e 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: nl.roomsoverview -version: 1.0.3 +version: 1.0.4 license: MIT modules: - roomsoverview diff --git a/roomsoverview.mbp b/roomsoverview.mbp index 65ed30b..7520615 100644 Binary files a/roomsoverview.mbp and b/roomsoverview.mbp differ diff --git a/roomsoverview.py b/roomsoverview.py index 2c28d55..cfd1c55 100644 --- a/roomsoverview.py +++ b/roomsoverview.py @@ -2,10 +2,14 @@ import asyncio from typing import Any, Dict, List, Optional, Tuple from urllib.parse import quote +import aiohttp + from maubot import Plugin, MessageEvent from maubot.handlers import command from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper +_REQUEST_TIMEOUT = aiohttp.ClientTimeout(total=30) + def _escape_md(text: str) -> str: """Escape markdown-significant characters when embedding user content.""" @@ -38,7 +42,7 @@ class RoomsOverviewPlugin(Plugin): return Config async def _fetch_hierarchy(self, space_id: str) -> Tuple[List[Dict[str, Any]], bool]: - """Fetch the full paginated space hierarchy for a room. + """Fetch the paginated space hierarchy for a room. Uses GET /_matrix/client/v1/rooms/{roomId}/hierarchy, which paginates depth-first over the whole space tree. Retries on 429 @@ -75,7 +79,9 @@ class RoomsOverviewPlugin(Plugin): retries = 0 while True: try: - async with self.http.get(url, params=params, headers=headers) as resp: + async with self.http.get( + url, params=params, headers=headers, timeout=_REQUEST_TIMEOUT + ) as resp: if resp.status == 429: retries += 1 try: