Skip to content

Commit

Permalink
Also set user_id for authenticated downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jul 9, 2024
1 parent 3e89f1f commit d645e20
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mautrix/client/api/modules/media_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ async def download_media(self, url: ContentURI, timeout_ms: int | None = None) -
headers: dict[str, str] = {}
if authenticated:
headers["Authorization"] = f"Bearer {self.api.token}"
if self.api.as_user_id:
query_params["user_id"] = self.api.as_user_id
req_id = self.api.log_download_request(url, query_params)
start = time.monotonic()
async with self.api.session.get(url, params=query_params, headers=headers) as response:
Expand Down Expand Up @@ -248,6 +250,8 @@ async def download_thumbnail(
headers: dict[str, str] = {}
if authenticated:
headers["Authorization"] = f"Bearer {self.api.token}"
if self.api.as_user_id:
query_params["user_id"] = self.api.as_user_id
req_id = self.api.log_download_request(url, query_params)
start = time.monotonic()
async with self.api.session.get(url, params=query_params, headers=headers) as response:
Expand Down

0 comments on commit d645e20

Please sign in to comment.